home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / How_to_use2150884272009.psc / Ash-Sha1 MD5 / C source (test).txt < prev   
C/C++ Source or Header  |  2009-04-28  |  1MB  |  50,057 lines

  1. #include "mdx.h"
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. // READLEN % 64 must = 0
  7. #define READLEN    1048576L // 2^20, 1MB
  8.  
  9. void DigestFile( char * );
  10. void DigestString();
  11.  
  12. void main(int argc, char *argv[])
  13. {
  14.     printf("%s\n\n", MDxGetVersion());
  15.  
  16.     if( argc > 1 )
  17.         DigestFile( argv[1] );
  18.     else    
  19.         DigestString();
  20.  
  21. }
  22.  
  23. /*
  24.     I use the 'chunk' method for processing files not because of
  25.     limitations of my dll, but think what would happen if you
  26.     tried to load an entire cd image into memory.
  27. */
  28. void DigestFile( char *szFName )
  29. {
  30.     FILE *file;
  31.     void *lpData;
  32.     long flen, mlen;
  33.     MDxSum mdDataSum;
  34.     MDxSum md4DataSum;
  35.  
  36.     // the 64 is for padding purposes
  37.     lpData = malloc( READLEN + 64 );
  38.     
  39.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40.  
  41.     file = fopen( szFName, "rb" );
  42.     if( file == NULL )
  43.     {
  44.         printf("ERROR: File not found.\n");
  45.         return;
  46.     }
  47.     
  48.     MDxInit( &mdDataSum );
  49.     MDxInit( &md4DataSum );
  50.     
  51.     fseek( file, 0, SEEK_END );
  52.     //Get the file length
  53.     flen = mlen = ftell( file );
  54.     fseek( file, 0, SEEK_SET );
  55.     
  56.     // When it takes a while to process a large file,
  57.     // remember that for each chunk it has to run 
  58.     // through the main translation loop 16384 times!
  59.         
  60.     printf("Processing %ld byte file: .", flen );
  61.     
  62.     while( flen > READLEN )
  63.     {
  64.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  65.         {
  66.             printf("READ ERROR!\n");
  67.             return;
  68.         }
  69.         MD5Translate( lpData, READLEN, &mdDataSum );
  70.         MD4Translate( lpData, READLEN, &md4DataSum );
  71.         flen -= READLEN;
  72.         printf(".");
  73.     }
  74.  
  75.     if (fread( lpData, 1, flen, file ) != flen)
  76.     {
  77.         printf("READ ERROR!\n");
  78.         return;
  79.     }
  80.     // This is why I added the new argument to MDxPad
  81.     // So we can pass the length of the data AND the
  82.     // Total length of the message
  83.     // Also it now returns the # of padding bytes added,
  84.     // this is for files that are an exact multiple of the chunk
  85.     // length. (Otherwise the padding isn't Translated)
  86.     flen += MDxPad( lpData, flen, mlen );
  87.     MD5Translate( lpData, flen, &mdDataSum );    
  88.     MD4Translate( lpData, flen, &md4DataSum );
  89.  
  90.     // New step necessary because of the 'chunking' method
  91.     MDxFinalize( &mdDataSum );
  92.     MDxFinalize( &md4DataSum );
  93.     
  94.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  95.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  96.     fclose(file);
  97.         
  98. }
  99.  
  100. void DigestString()
  101. {
  102.     
  103.     //For our demo purposes, no strings bigger than 1024 :)
  104.     unsigned char lpData[1024] = "";
  105.     long len = 0;
  106.     MDxSum mdDataSum;
  107.  
  108.     printf("Enter the string to digest: ");
  109.     scanf("%s", &lpData );
  110.     len = strlen(lpData);
  111.     
  112.     // Have to do this before the Padding...well...it's best anyway;)
  113.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  114.     
  115.     // For the strings, we're gonna pad and digest the string
  116.     // in one pass.
  117.     MDxInit( &mdDataSum );
  118.     MDxPad( lpData, len, len );
  119.     
  120.     MD5Translate( lpData, len, &mdDataSum );
  121.         // New step necessary because of the 'chunking' method
  122.         MDxFinalize( &mdDataSum );
  123.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  124.     
  125.     MDxInit( &mdDataSum );
  126.     MD4Translate( lpData, len, &mdDataSum );    
  127.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  128.  
  129.     return;
  130. }
  131.  
  132.  
  133. -------------- Include
  134.  
  135. #ifndef __windows_h__
  136.         typedef unsigned long DWORD;
  137.         #define STDCALL _stdcall
  138. #endif
  139.  
  140. typedef struct 
  141. {
  142.     DWORD dwSum[4];
  143. }MDxSum;
  144.  
  145. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  146. void STDCALL MDxInit( MDxSum * );
  147. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  148. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  149. const char * STDCALL MDxGetVersion();
  150. void STDCALL MDxFinalize( MDxSum * );
  151.  
  152.  
  153.  
  154. #include "mdx.h"
  155. #include <stdlib.h>
  156. #include <stdio.h>
  157. #include <string.h>
  158.  
  159. // READLEN % 64 must = 0
  160. #define READLEN    1048576L // 2^20, 1MB
  161.  
  162. void DigestFile( char * );
  163. void DigestString();
  164.  
  165. void main(int argc, char *argv[])
  166. {
  167.     printf("%s\n\n", MDxGetVersion());
  168.  
  169.     if( argc > 1 )
  170.         DigestFile( argv[1] );
  171.     else    
  172.         DigestString();
  173.  
  174. }
  175.  
  176. /*
  177.     I use the 'chunk' method for processing files not because of
  178.     limitations of my dll, but think what would happen if you
  179.     tried to load an entire cd image into memory.
  180. */
  181. void DigestFile( char *szFName )
  182. {
  183.     FILE *file;
  184.     void *lpData;
  185.     long flen, mlen;
  186.     MDxSum mdDataSum;
  187.     MDxSum md4DataSum;
  188.  
  189.     // the 64 is for padding purposes
  190.     lpData = malloc( READLEN + 64 );
  191.     
  192.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  193.  
  194.     file = fopen( szFName, "rb" );
  195.     if( file == NULL )
  196.     {
  197.         printf("ERROR: File not found.\n");
  198.         return;
  199.     }
  200.     
  201.     MDxInit( &mdDataSum );
  202.     MDxInit( &md4DataSum );
  203.     
  204.     fseek( file, 0, SEEK_END );
  205.     //Get the file length
  206.     flen = mlen = ftell( file );
  207.     fseek( file, 0, SEEK_SET );
  208.     
  209.     // When it takes a while to process a large file,
  210.     // remember that for each chunk it has to run 
  211.     // through the main translation loop 16384 times!
  212.         
  213.     printf("Processing %ld byte file: .", flen );
  214.     
  215.     while( flen > READLEN )
  216.     {
  217.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  218.         {
  219.             printf("READ ERROR!\n");
  220.             return;
  221.         }
  222.         MD5Translate( lpData, READLEN, &mdDataSum );
  223.         MD4Translate( lpData, READLEN, &md4DataSum );
  224.         flen -= READLEN;
  225.         printf(".");
  226.     }
  227.  
  228.     if (fread( lpData, 1, flen, file ) != flen)
  229.     {
  230.         printf("READ ERROR!\n");
  231.         return;
  232.     }
  233.     // This is why I added the new argument to MDxPad
  234.     // So we can pass the length of the data AND the
  235.     // Total length of the message
  236.     // Also it now returns the # of padding bytes added,
  237.     // this is for files that are an exact multiple of the chunk
  238.     // length. (Otherwise the padding isn't Translated)
  239.     flen += MDxPad( lpData, flen, mlen );
  240.     MD5Translate( lpData, flen, &mdDataSum );    
  241.     MD4Translate( lpData, flen, &md4DataSum );
  242.  
  243.     // New step necessary because of the 'chunking' method
  244.     MDxFinalize( &mdDataSum );
  245.     MDxFinalize( &md4DataSum );
  246.     
  247.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  248.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  249.     fclose(file);
  250.         
  251. }
  252.  
  253. void DigestString()
  254. {
  255.     
  256.     //For our demo purposes, no strings bigger than 1024 :)
  257.     unsigned char lpData[1024] = "";
  258.     long len = 0;
  259.     MDxSum mdDataSum;
  260.  
  261.     printf("Enter the string to digest: ");
  262.     scanf("%s", &lpData );
  263.     len = strlen(lpData);
  264.     
  265.     // Have to do this before the Padding...well...it's best anyway;)
  266.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  267.     
  268.     // For the strings, we're gonna pad and digest the string
  269.     // in one pass.
  270.     MDxInit( &mdDataSum );
  271.     MDxPad( lpData, len, len );
  272.     
  273.     MD5Translate( lpData, len, &mdDataSum );
  274.         // New step necessary because of the 'chunking' method
  275.         MDxFinalize( &mdDataSum );
  276.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  277.     
  278.     MDxInit( &mdDataSum );
  279.     MD4Translate( lpData, len, &mdDataSum );    
  280.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  281.  
  282.     return;
  283. }
  284.  
  285.  
  286. -------------- Include
  287.  
  288. #ifndef __windows_h__
  289.         typedef unsigned long DWORD;
  290.         #define STDCALL _stdcall
  291. #endif
  292.  
  293. typedef struct 
  294. {
  295.     DWORD dwSum[4];
  296. }MDxSum;
  297.  
  298. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  299. void STDCALL MDxInit( MDxSum * );
  300. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  301. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  302. const char * STDCALL MDxGetVersion();
  303. void STDCALL MDxFinalize( MDxSum * );
  304.  
  305.  
  306.  
  307. #include "mdx.h"
  308. #include <stdlib.h>
  309. #include <stdio.h>
  310. #include <string.h>
  311.  
  312. // READLEN % 64 must = 0
  313. #define READLEN    1048576L // 2^20, 1MB
  314.  
  315. void DigestFile( char * );
  316. void DigestString();
  317.  
  318. void main(int argc, char *argv[])
  319. {
  320.     printf("%s\n\n", MDxGetVersion());
  321.  
  322.     if( argc > 1 )
  323.         DigestFile( argv[1] );
  324.     else    
  325.         DigestString();
  326.  
  327. }
  328.  
  329. /*
  330.     I use the 'chunk' method for processing files not because of
  331.     limitations of my dll, but think what would happen if you
  332.     tried to load an entire cd image into memory.
  333. */
  334. void DigestFile( char *szFName )
  335. {
  336.     FILE *file;
  337.     void *lpData;
  338.     long flen, mlen;
  339.     MDxSum mdDataSum;
  340.     MDxSum md4DataSum;
  341.  
  342.     // the 64 is for padding purposes
  343.     lpData = malloc( READLEN + 64 );
  344.     
  345.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  346.  
  347.     file = fopen( szFName, "rb" );
  348.     if( file == NULL )
  349.     {
  350.         printf("ERROR: File not found.\n");
  351.         return;
  352.     }
  353.     
  354.     MDxInit( &mdDataSum );
  355.     MDxInit( &md4DataSum );
  356.     
  357.     fseek( file, 0, SEEK_END );
  358.     //Get the file length
  359.     flen = mlen = ftell( file );
  360.     fseek( file, 0, SEEK_SET );
  361.     
  362.     // When it takes a while to process a large file,
  363.     // remember that for each chunk it has to run 
  364.     // through the main translation loop 16384 times!
  365.         
  366.     printf("Processing %ld byte file: .", flen );
  367.     
  368.     while( flen > READLEN )
  369.     {
  370.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  371.         {
  372.             printf("READ ERROR!\n");
  373.             return;
  374.         }
  375.         MD5Translate( lpData, READLEN, &mdDataSum );
  376.         MD4Translate( lpData, READLEN, &md4DataSum );
  377.         flen -= READLEN;
  378.         printf(".");
  379.     }
  380.  
  381.     if (fread( lpData, 1, flen, file ) != flen)
  382.     {
  383.         printf("READ ERROR!\n");
  384.         return;
  385.     }
  386.     // This is why I added the new argument to MDxPad
  387.     // So we can pass the length of the data AND the
  388.     // Total length of the message
  389.     // Also it now returns the # of padding bytes added,
  390.     // this is for files that are an exact multiple of the chunk
  391.     // length. (Otherwise the padding isn't Translated)
  392.     flen += MDxPad( lpData, flen, mlen );
  393.     MD5Translate( lpData, flen, &mdDataSum );    
  394.     MD4Translate( lpData, flen, &md4DataSum );
  395.  
  396.     // New step necessary because of the 'chunking' method
  397.     MDxFinalize( &mdDataSum );
  398.     MDxFinalize( &md4DataSum );
  399.     
  400.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  401.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  402.     fclose(file);
  403.         
  404. }
  405.  
  406. void DigestString()
  407. {
  408.     
  409.     //For our demo purposes, no strings bigger than 1024 :)
  410.     unsigned char lpData[1024] = "";
  411.     long len = 0;
  412.     MDxSum mdDataSum;
  413.  
  414.     printf("Enter the string to digest: ");
  415.     scanf("%s", &lpData );
  416.     len = strlen(lpData);
  417.     
  418.     // Have to do this before the Padding...well...it's best anyway;)
  419.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  420.     
  421.     // For the strings, we're gonna pad and digest the string
  422.     // in one pass.
  423.     MDxInit( &mdDataSum );
  424.     MDxPad( lpData, len, len );
  425.     
  426.     MD5Translate( lpData, len, &mdDataSum );
  427.         // New step necessary because of the 'chunking' method
  428.         MDxFinalize( &mdDataSum );
  429.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  430.     
  431.     MDxInit( &mdDataSum );
  432.     MD4Translate( lpData, len, &mdDataSum );    
  433.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  434.  
  435.     return;
  436. }
  437.  
  438.  
  439. -------------- Include
  440.  
  441. #ifndef __windows_h__
  442.         typedef unsigned long DWORD;
  443.         #define STDCALL _stdcall
  444. #endif
  445.  
  446. typedef struct 
  447. {
  448.     DWORD dwSum[4];
  449. }MDxSum;
  450.  
  451. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  452. void STDCALL MDxInit( MDxSum * );
  453. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  454. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  455. const char * STDCALL MDxGetVersion();
  456. void STDCALL MDxFinalize( MDxSum * );
  457.  
  458.  
  459.  
  460. #include "mdx.h"
  461. #include <stdlib.h>
  462. #include <stdio.h>
  463. #include <string.h>
  464.  
  465. // READLEN % 64 must = 0
  466. #define READLEN    1048576L // 2^20, 1MB
  467.  
  468. void DigestFile( char * );
  469. void DigestString();
  470.  
  471. void main(int argc, char *argv[])
  472. {
  473.     printf("%s\n\n", MDxGetVersion());
  474.  
  475.     if( argc > 1 )
  476.         DigestFile( argv[1] );
  477.     else    
  478.         DigestString();
  479.  
  480. }
  481.  
  482. /*
  483.     I use the 'chunk' method for processing files not because of
  484.     limitations of my dll, but think what would happen if you
  485.     tried to load an entire cd image into memory.
  486. */
  487. void DigestFile( char *szFName )
  488. {
  489.     FILE *file;
  490.     void *lpData;
  491.     long flen, mlen;
  492.     MDxSum mdDataSum;
  493.     MDxSum md4DataSum;
  494.  
  495.     // the 64 is for padding purposes
  496.     lpData = malloc( READLEN + 64 );
  497.     
  498.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  499.  
  500.     file = fopen( szFName, "rb" );
  501.     if( file == NULL )
  502.     {
  503.         printf("ERROR: File not found.\n");
  504.         return;
  505.     }
  506.     
  507.     MDxInit( &mdDataSum );
  508.     MDxInit( &md4DataSum );
  509.     
  510.     fseek( file, 0, SEEK_END );
  511.     //Get the file length
  512.     flen = mlen = ftell( file );
  513.     fseek( file, 0, SEEK_SET );
  514.     
  515.     // When it takes a while to process a large file,
  516.     // remember that for each chunk it has to run 
  517.     // through the main translation loop 16384 times!
  518.         
  519.     printf("Processing %ld byte file: .", flen );
  520.     
  521.     while( flen > READLEN )
  522.     {
  523.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  524.         {
  525.             printf("READ ERROR!\n");
  526.             return;
  527.         }
  528.         MD5Translate( lpData, READLEN, &mdDataSum );
  529.         MD4Translate( lpData, READLEN, &md4DataSum );
  530.         flen -= READLEN;
  531.         printf(".");
  532.     }
  533.  
  534.     if (fread( lpData, 1, flen, file ) != flen)
  535.     {
  536.         printf("READ ERROR!\n");
  537.         return;
  538.     }
  539.     // This is why I added the new argument to MDxPad
  540.     // So we can pass the length of the data AND the
  541.     // Total length of the message
  542.     // Also it now returns the # of padding bytes added,
  543.     // this is for files that are an exact multiple of the chunk
  544.     // length. (Otherwise the padding isn't Translated)
  545.     flen += MDxPad( lpData, flen, mlen );
  546.     MD5Translate( lpData, flen, &mdDataSum );    
  547.     MD4Translate( lpData, flen, &md4DataSum );
  548.  
  549.     // New step necessary because of the 'chunking' method
  550.     MDxFinalize( &mdDataSum );
  551.     MDxFinalize( &md4DataSum );
  552.     
  553.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  554.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  555.     fclose(file);
  556.         
  557. }
  558.  
  559. void DigestString()
  560. {
  561.     
  562.     //For our demo purposes, no strings bigger than 1024 :)
  563.     unsigned char lpData[1024] = "";
  564.     long len = 0;
  565.     MDxSum mdDataSum;
  566.  
  567.     printf("Enter the string to digest: ");
  568.     scanf("%s", &lpData );
  569.     len = strlen(lpData);
  570.     
  571.     // Have to do this before the Padding...well...it's best anyway;)
  572.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  573.     
  574.     // For the strings, we're gonna pad and digest the string
  575.     // in one pass.
  576.     MDxInit( &mdDataSum );
  577.     MDxPad( lpData, len, len );
  578.     
  579.     MD5Translate( lpData, len, &mdDataSum );
  580.         // New step necessary because of the 'chunking' method
  581.         MDxFinalize( &mdDataSum );
  582.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  583.     
  584.     MDxInit( &mdDataSum );
  585.     MD4Translate( lpData, len, &mdDataSum );    
  586.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  587.  
  588.     return;
  589. }
  590.  
  591.  
  592. -------------- Include
  593.  
  594. #ifndef __windows_h__
  595.         typedef unsigned long DWORD;
  596.         #define STDCALL _stdcall
  597. #endif
  598.  
  599. typedef struct 
  600. {
  601.     DWORD dwSum[4];
  602. }MDxSum;
  603.  
  604. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  605. void STDCALL MDxInit( MDxSum * );
  606. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  607. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  608. const char * STDCALL MDxGetVersion();
  609. void STDCALL MDxFinalize( MDxSum * );
  610.  
  611.  
  612.  
  613. #include "mdx.h"
  614. #include <stdlib.h>
  615. #include <stdio.h>
  616. #include <string.h>
  617.  
  618. // READLEN % 64 must = 0
  619. #define READLEN    1048576L // 2^20, 1MB
  620.  
  621. void DigestFile( char * );
  622. void DigestString();
  623.  
  624. void main(int argc, char *argv[])
  625. {
  626.     printf("%s\n\n", MDxGetVersion());
  627.  
  628.     if( argc > 1 )
  629.         DigestFile( argv[1] );
  630.     else    
  631.         DigestString();
  632.  
  633. }
  634.  
  635. /*
  636.     I use the 'chunk' method for processing files not because of
  637.     limitations of my dll, but think what would happen if you
  638.     tried to load an entire cd image into memory.
  639. */
  640. void DigestFile( char *szFName )
  641. {
  642.     FILE *file;
  643.     void *lpData;
  644.     long flen, mlen;
  645.     MDxSum mdDataSum;
  646.     MDxSum md4DataSum;
  647.  
  648.     // the 64 is for padding purposes
  649.     lpData = malloc( READLEN + 64 );
  650.     
  651.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  652.  
  653.     file = fopen( szFName, "rb" );
  654.     if( file == NULL )
  655.     {
  656.         printf("ERROR: File not found.\n");
  657.         return;
  658.     }
  659.     
  660.     MDxInit( &mdDataSum );
  661.     MDxInit( &md4DataSum );
  662.     
  663.     fseek( file, 0, SEEK_END );
  664.     //Get the file length
  665.     flen = mlen = ftell( file );
  666.     fseek( file, 0, SEEK_SET );
  667.     
  668.     // When it takes a while to process a large file,
  669.     // remember that for each chunk it has to run 
  670.     // through the main translation loop 16384 times!
  671.         
  672.     printf("Processing %ld byte file: .", flen );
  673.     
  674.     while( flen > READLEN )
  675.     {
  676.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  677.         {
  678.             printf("READ ERROR!\n");
  679.             return;
  680.         }
  681.         MD5Translate( lpData, READLEN, &mdDataSum );
  682.         MD4Translate( lpData, READLEN, &md4DataSum );
  683.         flen -= READLEN;
  684.         printf(".");
  685.     }
  686.  
  687.     if (fread( lpData, 1, flen, file ) != flen)
  688.     {
  689.         printf("READ ERROR!\n");
  690.         return;
  691.     }
  692.     // This is why I added the new argument to MDxPad
  693.     // So we can pass the length of the data AND the
  694.     // Total length of the message
  695.     // Also it now returns the # of padding bytes added,
  696.     // this is for files that are an exact multiple of the chunk
  697.     // length. (Otherwise the padding isn't Translated)
  698.     flen += MDxPad( lpData, flen, mlen );
  699.     MD5Translate( lpData, flen, &mdDataSum );    
  700.     MD4Translate( lpData, flen, &md4DataSum );
  701.  
  702.     // New step necessary because of the 'chunking' method
  703.     MDxFinalize( &mdDataSum );
  704.     MDxFinalize( &md4DataSum );
  705.     
  706.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  707.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  708.     fclose(file);
  709.         
  710. }
  711.  
  712. void DigestString()
  713. {
  714.     
  715.     //For our demo purposes, no strings bigger than 1024 :)
  716.     unsigned char lpData[1024] = "";
  717.     long len = 0;
  718.     MDxSum mdDataSum;
  719.  
  720.     printf("Enter the string to digest: ");
  721.     scanf("%s", &lpData );
  722.     len = strlen(lpData);
  723.     
  724.     // Have to do this before the Padding...well...it's best anyway;)
  725.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  726.     
  727.     // For the strings, we're gonna pad and digest the string
  728.     // in one pass.
  729.     MDxInit( &mdDataSum );
  730.     MDxPad( lpData, len, len );
  731.     
  732.     MD5Translate( lpData, len, &mdDataSum );
  733.         // New step necessary because of the 'chunking' method
  734.         MDxFinalize( &mdDataSum );
  735.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  736.     
  737.     MDxInit( &mdDataSum );
  738.     MD4Translate( lpData, len, &mdDataSum );    
  739.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  740.  
  741.     return;
  742. }
  743.  
  744.  
  745. -------------- Include
  746.  
  747. #ifndef __windows_h__
  748.         typedef unsigned long DWORD;
  749.         #define STDCALL _stdcall
  750. #endif
  751.  
  752. typedef struct 
  753. {
  754.     DWORD dwSum[4];
  755. }MDxSum;
  756.  
  757. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  758. void STDCALL MDxInit( MDxSum * );
  759. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  760. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  761. const char * STDCALL MDxGetVersion();
  762. void STDCALL MDxFinalize( MDxSum * );
  763.  
  764.  
  765.  
  766.  
  767. #include "mdx.h"
  768. #include <stdlib.h>
  769. #include <stdio.h>
  770. #include <string.h>
  771.  
  772. // READLEN % 64 must = 0
  773. #define READLEN    1048576L // 2^20, 1MB
  774.  
  775. void DigestFile( char * );
  776. void DigestString();
  777.  
  778. void main(int argc, char *argv[])
  779. {
  780.     printf("%s\n\n", MDxGetVersion());
  781.  
  782.     if( argc > 1 )
  783.         DigestFile( argv[1] );
  784.     else    
  785.         DigestString();
  786.  
  787. }
  788.  
  789. /*
  790.     I use the 'chunk' method for processing files not because of
  791.     limitations of my dll, but think what would happen if you
  792.     tried to load an entire cd image into memory.
  793. */
  794. void DigestFile( char *szFName )
  795. {
  796.     FILE *file;
  797.     void *lpData;
  798.     long flen, mlen;
  799.     MDxSum mdDataSum;
  800.     MDxSum md4DataSum;
  801.  
  802.     // the 64 is for padding purposes
  803.     lpData = malloc( READLEN + 64 );
  804.     
  805.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  806.  
  807.     file = fopen( szFName, "rb" );
  808.     if( file == NULL )
  809.     {
  810.         printf("ERROR: File not found.\n");
  811.         return;
  812.     }
  813.     
  814.     MDxInit( &mdDataSum );
  815.     MDxInit( &md4DataSum );
  816.     
  817.     fseek( file, 0, SEEK_END );
  818.     //Get the file length
  819.     flen = mlen = ftell( file );
  820.     fseek( file, 0, SEEK_SET );
  821.     
  822.     // When it takes a while to process a large file,
  823.     // remember that for each chunk it has to run 
  824.     // through the main translation loop 16384 times!
  825.         
  826.     printf("Processing %ld byte file: .", flen );
  827.     
  828.     while( flen > READLEN )
  829.     {
  830.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  831.         {
  832.             printf("READ ERROR!\n");
  833.             return;
  834.         }
  835.         MD5Translate( lpData, READLEN, &mdDataSum );
  836.         MD4Translate( lpData, READLEN, &md4DataSum );
  837.         flen -= READLEN;
  838.         printf(".");
  839.     }
  840.  
  841.     if (fread( lpData, 1, flen, file ) != flen)
  842.     {
  843.         printf("READ ERROR!\n");
  844.         return;
  845.     }
  846.     // This is why I added the new argument to MDxPad
  847.     // So we can pass the length of the data AND the
  848.     // Total length of the message
  849.     // Also it now returns the # of padding bytes added,
  850.     // this is for files that are an exact multiple of the chunk
  851.     // length. (Otherwise the padding isn't Translated)
  852.     flen += MDxPad( lpData, flen, mlen );
  853.     MD5Translate( lpData, flen, &mdDataSum );    
  854.     MD4Translate( lpData, flen, &md4DataSum );
  855.  
  856.     // New step necessary because of the 'chunking' method
  857.     MDxFinalize( &mdDataSum );
  858.     MDxFinalize( &md4DataSum );
  859.     
  860.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  861.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  862.     fclose(file);
  863.         
  864. }
  865.  
  866. void DigestString()
  867. {
  868.     
  869.     //For our demo purposes, no strings bigger than 1024 :)
  870.     unsigned char lpData[1024] = "";
  871.     long len = 0;
  872.     MDxSum mdDataSum;
  873.  
  874.     printf("Enter the string to digest: ");
  875.     scanf("%s", &lpData );
  876.     len = strlen(lpData);
  877.     
  878.     // Have to do this before the Padding...well...it's best anyway;)
  879.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  880.     
  881.     // For the strings, we're gonna pad and digest the string
  882.     // in one pass.
  883.     MDxInit( &mdDataSum );
  884.     MDxPad( lpData, len, len );
  885.     
  886.     MD5Translate( lpData, len, &mdDataSum );
  887.         // New step necessary because of the 'chunking' method
  888.         MDxFinalize( &mdDataSum );
  889.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  890.     
  891.     MDxInit( &mdDataSum );
  892.     MD4Translate( lpData, len, &mdDataSum );    
  893.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  894.  
  895.     return;
  896. }
  897.  
  898.  
  899. -------------- Include
  900.  
  901. #ifndef __windows_h__
  902.         typedef unsigned long DWORD;
  903.         #define STDCALL _stdcall
  904. #endif
  905.  
  906. typedef struct 
  907. {
  908.     DWORD dwSum[4];
  909. }MDxSum;
  910.  
  911. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  912. void STDCALL MDxInit( MDxSum * );
  913. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  914. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  915. const char * STDCALL MDxGetVersion();
  916. void STDCALL MDxFinalize( MDxSum * );
  917.  
  918.  
  919.  
  920.  
  921. #include "mdx.h"
  922. #include <stdlib.h>
  923. #include <stdio.h>
  924. #include <string.h>
  925.  
  926. // READLEN % 64 must = 0
  927. #define READLEN    1048576L // 2^20, 1MB
  928.  
  929. void DigestFile( char * );
  930. void DigestString();
  931.  
  932. void main(int argc, char *argv[])
  933. {
  934.     printf("%s\n\n", MDxGetVersion());
  935.  
  936.     if( argc > 1 )
  937.         DigestFile( argv[1] );
  938.     else    
  939.         DigestString();
  940.  
  941. }
  942.  
  943. /*
  944.     I use the 'chunk' method for processing files not because of
  945.     limitations of my dll, but think what would happen if you
  946.     tried to load an entire cd image into memory.
  947. */
  948. void DigestFile( char *szFName )
  949. {
  950.     FILE *file;
  951.     void *lpData;
  952.     long flen, mlen;
  953.     MDxSum mdDataSum;
  954.     MDxSum md4DataSum;
  955.  
  956.     // the 64 is for padding purposes
  957.     lpData = malloc( READLEN + 64 );
  958.     
  959.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  960.  
  961.     file = fopen( szFName, "rb" );
  962.     if( file == NULL )
  963.     {
  964.         printf("ERROR: File not found.\n");
  965.         return;
  966.     }
  967.     
  968.     MDxInit( &mdDataSum );
  969.     MDxInit( &md4DataSum );
  970.     
  971.     fseek( file, 0, SEEK_END );
  972.     //Get the file length
  973.     flen = mlen = ftell( file );
  974.     fseek( file, 0, SEEK_SET );
  975.     
  976.     // When it takes a while to process a large file,
  977.     // remember that for each chunk it has to run 
  978.     // through the main translation loop 16384 times!
  979.         
  980.     printf("Processing %ld byte file: .", flen );
  981.     
  982.     while( flen > READLEN )
  983.     {
  984.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  985.         {
  986.             printf("READ ERROR!\n");
  987.             return;
  988.         }
  989.         MD5Translate( lpData, READLEN, &mdDataSum );
  990.         MD4Translate( lpData, READLEN, &md4DataSum );
  991.         flen -= READLEN;
  992.         printf(".");
  993.     }
  994.  
  995.     if (fread( lpData, 1, flen, file ) != flen)
  996.     {
  997.         printf("READ ERROR!\n");
  998.         return;
  999.     }
  1000.     // This is why I added the new argument to MDxPad
  1001.     // So we can pass the length of the data AND the
  1002.     // Total length of the message
  1003.     // Also it now returns the # of padding bytes added,
  1004.     // this is for files that are an exact multiple of the chunk
  1005.     // length. (Otherwise the padding isn't Translated)
  1006.     flen += MDxPad( lpData, flen, mlen );
  1007.     MD5Translate( lpData, flen, &mdDataSum );    
  1008.     MD4Translate( lpData, flen, &md4DataSum );
  1009.  
  1010.     // New step necessary because of the 'chunking' method
  1011.     MDxFinalize( &mdDataSum );
  1012.     MDxFinalize( &md4DataSum );
  1013.     
  1014.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1015.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1016.     fclose(file);
  1017.         
  1018. }
  1019.  
  1020. void DigestString()
  1021. {
  1022.     
  1023.     //For our demo purposes, no strings bigger than 1024 :)
  1024.     unsigned char lpData[1024] = "";
  1025.     long len = 0;
  1026.     MDxSum mdDataSum;
  1027.  
  1028.     printf("Enter the string to digest: ");
  1029.     scanf("%s", &lpData );
  1030.     len = strlen(lpData);
  1031.     
  1032.     // Have to do this before the Padding...well...it's best anyway;)
  1033.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1034.     
  1035.     // For the strings, we're gonna pad and digest the string
  1036.     // in one pass.
  1037.     MDxInit( &mdDataSum );
  1038.     MDxPad( lpData, len, len );
  1039.     
  1040.     MD5Translate( lpData, len, &mdDataSum );
  1041.         // New step necessary because of the 'chunking' method
  1042.         MDxFinalize( &mdDataSum );
  1043.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1044.     
  1045.     MDxInit( &mdDataSum );
  1046.     MD4Translate( lpData, len, &mdDataSum );    
  1047.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1048.  
  1049.     return;
  1050. }
  1051.  
  1052.  
  1053. -------------- Include
  1054.  
  1055. #ifndef __windows_h__
  1056.         typedef unsigned long DWORD;
  1057.         #define STDCALL _stdcall
  1058. #endif
  1059.  
  1060. typedef struct 
  1061. {
  1062.     DWORD dwSum[4];
  1063. }MDxSum;
  1064.  
  1065. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1066. void STDCALL MDxInit( MDxSum * );
  1067. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1068. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1069. const char * STDCALL MDxGetVersion();
  1070. void STDCALL MDxFinalize( MDxSum * );
  1071.  
  1072.  
  1073.  
  1074.  
  1075. #include "mdx.h"
  1076. #include <stdlib.h>
  1077. #include <stdio.h>
  1078. #include <string.h>
  1079.  
  1080. // READLEN % 64 must = 0
  1081. #define READLEN    1048576L // 2^20, 1MB
  1082.  
  1083. void DigestFile( char * );
  1084. void DigestString();
  1085.  
  1086. void main(int argc, char *argv[])
  1087. {
  1088.     printf("%s\n\n", MDxGetVersion());
  1089.  
  1090.     if( argc > 1 )
  1091.         DigestFile( argv[1] );
  1092.     else    
  1093.         DigestString();
  1094.  
  1095. }
  1096.  
  1097. /*
  1098.     I use the 'chunk' method for processing files not because of
  1099.     limitations of my dll, but think what would happen if you
  1100.     tried to load an entire cd image into memory.
  1101. */
  1102. void DigestFile( char *szFName )
  1103. {
  1104.     FILE *file;
  1105.     void *lpData;
  1106.     long flen, mlen;
  1107.     MDxSum mdDataSum;
  1108.     MDxSum md4DataSum;
  1109.  
  1110.     // the 64 is for padding purposes
  1111.     lpData = malloc( READLEN + 64 );
  1112.     
  1113.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  1114.  
  1115.     file = fopen( szFName, "rb" );
  1116.     if( file == NULL )
  1117.     {
  1118.         printf("ERROR: File not found.\n");
  1119.         return;
  1120.     }
  1121.     
  1122.     MDxInit( &mdDataSum );
  1123.     MDxInit( &md4DataSum );
  1124.     
  1125.     fseek( file, 0, SEEK_END );
  1126.     //Get the file length
  1127.     flen = mlen = ftell( file );
  1128.     fseek( file, 0, SEEK_SET );
  1129.     
  1130.     // When it takes a while to process a large file,
  1131.     // remember that for each chunk it has to run 
  1132.     // through the main translation loop 16384 times!
  1133.         
  1134.     printf("Processing %ld byte file: .", flen );
  1135.     
  1136.     while( flen > READLEN )
  1137.     {
  1138.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  1139.         {
  1140.             printf("READ ERROR!\n");
  1141.             return;
  1142.         }
  1143.         MD5Translate( lpData, READLEN, &mdDataSum );
  1144.         MD4Translate( lpData, READLEN, &md4DataSum );
  1145.         flen -= READLEN;
  1146.         printf(".");
  1147.     }
  1148.  
  1149.     if (fread( lpData, 1, flen, file ) != flen)
  1150.     {
  1151.         printf("READ ERROR!\n");
  1152.         return;
  1153.     }
  1154.     // This is why I added the new argument to MDxPad
  1155.     // So we can pass the length of the data AND the
  1156.     // Total length of the message
  1157.     // Also it now returns the # of padding bytes added,
  1158.     // this is for files that are an exact multiple of the chunk
  1159.     // length. (Otherwise the padding isn't Translated)
  1160.     flen += MDxPad( lpData, flen, mlen );
  1161.     MD5Translate( lpData, flen, &mdDataSum );    
  1162.     MD4Translate( lpData, flen, &md4DataSum );
  1163.  
  1164.     // New step necessary because of the 'chunking' method
  1165.     MDxFinalize( &mdDataSum );
  1166.     MDxFinalize( &md4DataSum );
  1167.     
  1168.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1169.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1170.     fclose(file);
  1171.         
  1172. }
  1173.  
  1174. void DigestString()
  1175. {
  1176.     
  1177.     //For our demo purposes, no strings bigger than 1024 :)
  1178.     unsigned char lpData[1024] = "";
  1179.     long len = 0;
  1180.     MDxSum mdDataSum;
  1181.  
  1182.     printf("Enter the string to digest: ");
  1183.     scanf("%s", &lpData );
  1184.     len = strlen(lpData);
  1185.     
  1186.     // Have to do this before the Padding...well...it's best anyway;)
  1187.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1188.     
  1189.     // For the strings, we're gonna pad and digest the string
  1190.     // in one pass.
  1191.     MDxInit( &mdDataSum );
  1192.     MDxPad( lpData, len, len );
  1193.     
  1194.     MD5Translate( lpData, len, &mdDataSum );
  1195.         // New step necessary because of the 'chunking' method
  1196.         MDxFinalize( &mdDataSum );
  1197.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1198.     
  1199.     MDxInit( &mdDataSum );
  1200.     MD4Translate( lpData, len, &mdDataSum );    
  1201.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1202.  
  1203.     return;
  1204. }
  1205.  
  1206.  
  1207. -------------- Include
  1208.  
  1209. #ifndef __windows_h__
  1210.         typedef unsigned long DWORD;
  1211.         #define STDCALL _stdcall
  1212. #endif
  1213.  
  1214. typedef struct 
  1215. {
  1216.     DWORD dwSum[4];
  1217. }MDxSum;
  1218.  
  1219. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1220. void STDCALL MDxInit( MDxSum * );
  1221. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1222. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1223. const char * STDCALL MDxGetVersion();
  1224. void STDCALL MDxFinalize( MDxSum * );
  1225.  
  1226.  
  1227.  
  1228. #include "mdx.h"
  1229. #include <stdlib.h>
  1230. #include <stdio.h>
  1231. #include <string.h>
  1232.  
  1233. // READLEN % 64 must = 0
  1234. #define READLEN    1048576L // 2^20, 1MB
  1235.  
  1236. void DigestFile( char * );
  1237. void DigestString();
  1238.  
  1239. void main(int argc, char *argv[])
  1240. {
  1241.     printf("%s\n\n", MDxGetVersion());
  1242.  
  1243.     if( argc > 1 )
  1244.         DigestFile( argv[1] );
  1245.     else    
  1246.         DigestString();
  1247.  
  1248. }
  1249.  
  1250. /*
  1251.     I use the 'chunk' method for processing files not because of
  1252.     limitations of my dll, but think what would happen if you
  1253.     tried to load an entire cd image into memory.
  1254. */
  1255. void DigestFile( char *szFName )
  1256. {
  1257.     FILE *file;
  1258.     void *lpData;
  1259.     long flen, mlen;
  1260.     MDxSum mdDataSum;
  1261.     MDxSum md4DataSum;
  1262.  
  1263.     // the 64 is for padding purposes
  1264.     lpData = malloc( READLEN + 64 );
  1265.     
  1266.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  1267.  
  1268.     file = fopen( szFName, "rb" );
  1269.     if( file == NULL )
  1270.     {
  1271.         printf("ERROR: File not found.\n");
  1272.         return;
  1273.     }
  1274.     
  1275.     MDxInit( &mdDataSum );
  1276.     MDxInit( &md4DataSum );
  1277.     
  1278.     fseek( file, 0, SEEK_END );
  1279.     //Get the file length
  1280.     flen = mlen = ftell( file );
  1281.     fseek( file, 0, SEEK_SET );
  1282.     
  1283.     // When it takes a while to process a large file,
  1284.     // remember that for each chunk it has to run 
  1285.     // through the main translation loop 16384 times!
  1286.         
  1287.     printf("Processing %ld byte file: .", flen );
  1288.     
  1289.     while( flen > READLEN )
  1290.     {
  1291.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  1292.         {
  1293.             printf("READ ERROR!\n");
  1294.             return;
  1295.         }
  1296.         MD5Translate( lpData, READLEN, &mdDataSum );
  1297.         MD4Translate( lpData, READLEN, &md4DataSum );
  1298.         flen -= READLEN;
  1299.         printf(".");
  1300.     }
  1301.  
  1302.     if (fread( lpData, 1, flen, file ) != flen)
  1303.     {
  1304.         printf("READ ERROR!\n");
  1305.         return;
  1306.     }
  1307.     // This is why I added the new argument to MDxPad
  1308.     // So we can pass the length of the data AND the
  1309.     // Total length of the message
  1310.     // Also it now returns the # of padding bytes added,
  1311.     // this is for files that are an exact multiple of the chunk
  1312.     // length. (Otherwise the padding isn't Translated)
  1313.     flen += MDxPad( lpData, flen, mlen );
  1314.     MD5Translate( lpData, flen, &mdDataSum );    
  1315.     MD4Translate( lpData, flen, &md4DataSum );
  1316.  
  1317.     // New step necessary because of the 'chunking' method
  1318.     MDxFinalize( &mdDataSum );
  1319.     MDxFinalize( &md4DataSum );
  1320.     
  1321.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1322.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1323.     fclose(file);
  1324.         
  1325. }
  1326.  
  1327. void DigestString()
  1328. {
  1329.     
  1330.     //For our demo purposes, no strings bigger than 1024 :)
  1331.     unsigned char lpData[1024] = "";
  1332.     long len = 0;
  1333.     MDxSum mdDataSum;
  1334.  
  1335.     printf("Enter the string to digest: ");
  1336.     scanf("%s", &lpData );
  1337.     len = strlen(lpData);
  1338.     
  1339.     // Have to do this before the Padding...well...it's best anyway;)
  1340.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1341.     
  1342.     // For the strings, we're gonna pad and digest the string
  1343.     // in one pass.
  1344.     MDxInit( &mdDataSum );
  1345.     MDxPad( lpData, len, len );
  1346.     
  1347.     MD5Translate( lpData, len, &mdDataSum );
  1348.         // New step necessary because of the 'chunking' method
  1349.         MDxFinalize( &mdDataSum );
  1350.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1351.     
  1352.     MDxInit( &mdDataSum );
  1353.     MD4Translate( lpData, len, &mdDataSum );    
  1354.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1355.  
  1356.     return;
  1357. }
  1358.  
  1359.  
  1360. -------------- Include
  1361.  
  1362. #ifndef __windows_h__
  1363.         typedef unsigned long DWORD;
  1364.         #define STDCALL _stdcall
  1365. #endif
  1366.  
  1367. typedef struct 
  1368. {
  1369.     DWORD dwSum[4];
  1370. }MDxSum;
  1371.  
  1372. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1373. void STDCALL MDxInit( MDxSum * );
  1374. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1375. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1376. const char * STDCALL MDxGetVersion();
  1377. void STDCALL MDxFinalize( MDxSum * );
  1378.  
  1379.  
  1380.  
  1381. #include "mdx.h"
  1382. #include <stdlib.h>
  1383. #include <stdio.h>
  1384. #include <string.h>
  1385.  
  1386. // READLEN % 64 must = 0
  1387. #define READLEN    1048576L // 2^20, 1MB
  1388.  
  1389. void DigestFile( char * );
  1390. void DigestString();
  1391.  
  1392. void main(int argc, char *argv[])
  1393. {
  1394.     printf("%s\n\n", MDxGetVersion());
  1395.  
  1396.     if( argc > 1 )
  1397.         DigestFile( argv[1] );
  1398.     else    
  1399.         DigestString();
  1400.  
  1401. }
  1402.  
  1403. /*
  1404.     I use the 'chunk' method for processing files not because of
  1405.     limitations of my dll, but think what would happen if you
  1406.     tried to load an entire cd image into memory.
  1407. */
  1408. void DigestFile( char *szFName )
  1409. {
  1410.     FILE *file;
  1411.     void *lpData;
  1412.     long flen, mlen;
  1413.     MDxSum mdDataSum;
  1414.     MDxSum md4DataSum;
  1415.  
  1416.     // the 64 is for padding purposes
  1417.     lpData = malloc( READLEN + 64 );
  1418.     
  1419.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  1420.  
  1421.     file = fopen( szFName, "rb" );
  1422.     if( file == NULL )
  1423.     {
  1424.         printf("ERROR: File not found.\n");
  1425.         return;
  1426.     }
  1427.     
  1428.     MDxInit( &mdDataSum );
  1429.     MDxInit( &md4DataSum );
  1430.     
  1431.     fseek( file, 0, SEEK_END );
  1432.     //Get the file length
  1433.     flen = mlen = ftell( file );
  1434.     fseek( file, 0, SEEK_SET );
  1435.     
  1436.     // When it takes a while to process a large file,
  1437.     // remember that for each chunk it has to run 
  1438.     // through the main translation loop 16384 times!
  1439.         
  1440.     printf("Processing %ld byte file: .", flen );
  1441.     
  1442.     while( flen > READLEN )
  1443.     {
  1444.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  1445.         {
  1446.             printf("READ ERROR!\n");
  1447.             return;
  1448.         }
  1449.         MD5Translate( lpData, READLEN, &mdDataSum );
  1450.         MD4Translate( lpData, READLEN, &md4DataSum );
  1451.         flen -= READLEN;
  1452.         printf(".");
  1453.     }
  1454.  
  1455.     if (fread( lpData, 1, flen, file ) != flen)
  1456.     {
  1457.         printf("READ ERROR!\n");
  1458.         return;
  1459.     }
  1460.     // This is why I added the new argument to MDxPad
  1461.     // So we can pass the length of the data AND the
  1462.     // Total length of the message
  1463.     // Also it now returns the # of padding bytes added,
  1464.     // this is for files that are an exact multiple of the chunk
  1465.     // length. (Otherwise the padding isn't Translated)
  1466.     flen += MDxPad( lpData, flen, mlen );
  1467.     MD5Translate( lpData, flen, &mdDataSum );    
  1468.     MD4Translate( lpData, flen, &md4DataSum );
  1469.  
  1470.     // New step necessary because of the 'chunking' method
  1471.     MDxFinalize( &mdDataSum );
  1472.     MDxFinalize( &md4DataSum );
  1473.     
  1474.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1475.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1476.     fclose(file);
  1477.         
  1478. }
  1479.  
  1480. void DigestString()
  1481. {
  1482.     
  1483.     //For our demo purposes, no strings bigger than 1024 :)
  1484.     unsigned char lpData[1024] = "";
  1485.     long len = 0;
  1486.     MDxSum mdDataSum;
  1487.  
  1488.     printf("Enter the string to digest: ");
  1489.     scanf("%s", &lpData );
  1490.     len = strlen(lpData);
  1491.     
  1492.     // Have to do this before the Padding...well...it's best anyway;)
  1493.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1494.     
  1495.     // For the strings, we're gonna pad and digest the string
  1496.     // in one pass.
  1497.     MDxInit( &mdDataSum );
  1498.     MDxPad( lpData, len, len );
  1499.     
  1500.     MD5Translate( lpData, len, &mdDataSum );
  1501.         // New step necessary because of the 'chunking' method
  1502.         MDxFinalize( &mdDataSum );
  1503.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1504.     
  1505.     MDxInit( &mdDataSum );
  1506.     MD4Translate( lpData, len, &mdDataSum );    
  1507.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1508.  
  1509.     return;
  1510. }
  1511.  
  1512.  
  1513. -------------- Include
  1514.  
  1515. #ifndef __windows_h__
  1516.         typedef unsigned long DWORD;
  1517.         #define STDCALL _stdcall
  1518. #endif
  1519.  
  1520. typedef struct 
  1521. {
  1522.     DWORD dwSum[4];
  1523. }MDxSum;
  1524.  
  1525. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1526. void STDCALL MDxInit( MDxSum * );
  1527. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1528. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1529. const char * STDCALL MDxGetVersion();
  1530. void STDCALL MDxFinalize( MDxSum * );
  1531.  
  1532.  
  1533.  
  1534.  
  1535. #include "mdx.h"
  1536. #include <stdlib.h>
  1537. #include <stdio.h>
  1538. #include <string.h>
  1539.  
  1540. // READLEN % 64 must = 0
  1541. #define READLEN    1048576L // 2^20, 1MB
  1542.  
  1543. void DigestFile( char * );
  1544. void DigestString();
  1545.  
  1546. void main(int argc, char *argv[])
  1547. {
  1548.     printf("%s\n\n", MDxGetVersion());
  1549.  
  1550.     if( argc > 1 )
  1551.         DigestFile( argv[1] );
  1552.     else    
  1553.         DigestString();
  1554.  
  1555. }
  1556.  
  1557. /*
  1558.     I use the 'chunk' method for processing files not because of
  1559.     limitations of my dll, but think what would happen if you
  1560.     tried to load an entire cd image into memory.
  1561. */
  1562. void DigestFile( char *szFName )
  1563. {
  1564.     FILE *file;
  1565.     void *lpData;
  1566.     long flen, mlen;
  1567.     MDxSum mdDataSum;
  1568.     MDxSum md4DataSum;
  1569.  
  1570.     // the 64 is for padding purposes
  1571.     lpData = malloc( READLEN + 64 );
  1572.     
  1573.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  1574.  
  1575.     file = fopen( szFName, "rb" );
  1576.     if( file == NULL )
  1577.     {
  1578.         printf("ERROR: File not found.\n");
  1579.         return;
  1580.     }
  1581.     
  1582.     MDxInit( &mdDataSum );
  1583.     MDxInit( &md4DataSum );
  1584.     
  1585.     fseek( file, 0, SEEK_END );
  1586.     //Get the file length
  1587.     flen = mlen = ftell( file );
  1588.     fseek( file, 0, SEEK_SET );
  1589.     
  1590.     // When it takes a while to process a large file,
  1591.     // remember that for each chunk it has to run 
  1592.     // through the main translation loop 16384 times!
  1593.         
  1594.     printf("Processing %ld byte file: .", flen );
  1595.     
  1596.     while( flen > READLEN )
  1597.     {
  1598.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  1599.         {
  1600.             printf("READ ERROR!\n");
  1601.             return;
  1602.         }
  1603.         MD5Translate( lpData, READLEN, &mdDataSum );
  1604.         MD4Translate( lpData, READLEN, &md4DataSum );
  1605.         flen -= READLEN;
  1606.         printf(".");
  1607.     }
  1608.  
  1609.     if (fread( lpData, 1, flen, file ) != flen)
  1610.     {
  1611.         printf("READ ERROR!\n");
  1612.         return;
  1613.     }
  1614.     // This is why I added the new argument to MDxPad
  1615.     // So we can pass the length of the data AND the
  1616.     // Total length of the message
  1617.     // Also it now returns the # of padding bytes added,
  1618.     // this is for files that are an exact multiple of the chunk
  1619.     // length. (Otherwise the padding isn't Translated)
  1620.     flen += MDxPad( lpData, flen, mlen );
  1621.     MD5Translate( lpData, flen, &mdDataSum );    
  1622.     MD4Translate( lpData, flen, &md4DataSum );
  1623.  
  1624.     // New step necessary because of the 'chunking' method
  1625.     MDxFinalize( &mdDataSum );
  1626.     MDxFinalize( &md4DataSum );
  1627.     
  1628.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1629.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1630.     fclose(file);
  1631.         
  1632. }
  1633.  
  1634. void DigestString()
  1635. {
  1636.     
  1637.     //For our demo purposes, no strings bigger than 1024 :)
  1638.     unsigned char lpData[1024] = "";
  1639.     long len = 0;
  1640.     MDxSum mdDataSum;
  1641.  
  1642.     printf("Enter the string to digest: ");
  1643.     scanf("%s", &lpData );
  1644.     len = strlen(lpData);
  1645.     
  1646.     // Have to do this before the Padding...well...it's best anyway;)
  1647.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1648.     
  1649.     // For the strings, we're gonna pad and digest the string
  1650.     // in one pass.
  1651.     MDxInit( &mdDataSum );
  1652.     MDxPad( lpData, len, len );
  1653.     
  1654.     MD5Translate( lpData, len, &mdDataSum );
  1655.         // New step necessary because of the 'chunking' method
  1656.         MDxFinalize( &mdDataSum );
  1657.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1658.     
  1659.     MDxInit( &mdDataSum );
  1660.     MD4Translate( lpData, len, &mdDataSum );    
  1661.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1662.  
  1663.     return;
  1664. }
  1665.  
  1666.  
  1667. -------------- Include
  1668.  
  1669. #ifndef __windows_h__
  1670.         typedef unsigned long DWORD;
  1671.         #define STDCALL _stdcall
  1672. #endif
  1673.  
  1674. typedef struct 
  1675. {
  1676.     DWORD dwSum[4];
  1677. }MDxSum;
  1678.  
  1679. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1680. void STDCALL MDxInit( MDxSum * );
  1681. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1682. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1683. const char * STDCALL MDxGetVersion();
  1684. void STDCALL MDxFinalize( MDxSum * );
  1685.  
  1686.  
  1687.  
  1688.  
  1689. #include "mdx.h"
  1690. #include <stdlib.h>
  1691. #include <stdio.h>
  1692. #include <string.h>
  1693.  
  1694. // READLEN % 64 must = 0
  1695. #define READLEN    1048576L // 2^20, 1MB
  1696.  
  1697. void DigestFile( char * );
  1698. void DigestString();
  1699.  
  1700. void main(int argc, char *argv[])
  1701. {
  1702.     printf("%s\n\n", MDxGetVersion());
  1703.  
  1704.     if( argc > 1 )
  1705.         DigestFile( argv[1] );
  1706.     else    
  1707.         DigestString();
  1708.  
  1709. }
  1710.  
  1711. /*
  1712.     I use the 'chunk' method for processing files not because of
  1713.     limitations of my dll, but think what would happen if you
  1714.     tried to load an entire cd image into memory.
  1715. */
  1716. void DigestFile( char *szFName )
  1717. {
  1718.     FILE *file;
  1719.     void *lpData;
  1720.     long flen, mlen;
  1721.     MDxSum mdDataSum;
  1722.     MDxSum md4DataSum;
  1723.  
  1724.     // the 64 is for padding purposes
  1725.     lpData = malloc( READLEN + 64 );
  1726.     
  1727.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  1728.  
  1729.     file = fopen( szFName, "rb" );
  1730.     if( file == NULL )
  1731.     {
  1732.         printf("ERROR: File not found.\n");
  1733.         return;
  1734.     }
  1735.     
  1736.     MDxInit( &mdDataSum );
  1737.     MDxInit( &md4DataSum );
  1738.     
  1739.     fseek( file, 0, SEEK_END );
  1740.     //Get the file length
  1741.     flen = mlen = ftell( file );
  1742.     fseek( file, 0, SEEK_SET );
  1743.     
  1744.     // When it takes a while to process a large file,
  1745.     // remember that for each chunk it has to run 
  1746.     // through the main translation loop 16384 times!
  1747.         
  1748.     printf("Processing %ld byte file: .", flen );
  1749.     
  1750.     while( flen > READLEN )
  1751.     {
  1752.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  1753.         {
  1754.             printf("READ ERROR!\n");
  1755.             return;
  1756.         }
  1757.         MD5Translate( lpData, READLEN, &mdDataSum );
  1758.         MD4Translate( lpData, READLEN, &md4DataSum );
  1759.         flen -= READLEN;
  1760.         printf(".");
  1761.     }
  1762.  
  1763.     if (fread( lpData, 1, flen, file ) != flen)
  1764.     {
  1765.         printf("READ ERROR!\n");
  1766.         return;
  1767.     }
  1768.     // This is why I added the new argument to MDxPad
  1769.     // So we can pass the length of the data AND the
  1770.     // Total length of the message
  1771.     // Also it now returns the # of padding bytes added,
  1772.     // this is for files that are an exact multiple of the chunk
  1773.     // length. (Otherwise the padding isn't Translated)
  1774.     flen += MDxPad( lpData, flen, mlen );
  1775.     MD5Translate( lpData, flen, &mdDataSum );    
  1776.     MD4Translate( lpData, flen, &md4DataSum );
  1777.  
  1778.     // New step necessary because of the 'chunking' method
  1779.     MDxFinalize( &mdDataSum );
  1780.     MDxFinalize( &md4DataSum );
  1781.     
  1782.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1783.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1784.     fclose(file);
  1785.         
  1786. }
  1787.  
  1788. void DigestString()
  1789. {
  1790.     
  1791.     //For our demo purposes, no strings bigger than 1024 :)
  1792.     unsigned char lpData[1024] = "";
  1793.     long len = 0;
  1794.     MDxSum mdDataSum;
  1795.  
  1796.     printf("Enter the string to digest: ");
  1797.     scanf("%s", &lpData );
  1798.     len = strlen(lpData);
  1799.     
  1800.     // Have to do this before the Padding...well...it's best anyway;)
  1801.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1802.     
  1803.     // For the strings, we're gonna pad and digest the string
  1804.     // in one pass.
  1805.     MDxInit( &mdDataSum );
  1806.     MDxPad( lpData, len, len );
  1807.     
  1808.     MD5Translate( lpData, len, &mdDataSum );
  1809.         // New step necessary because of the 'chunking' method
  1810.         MDxFinalize( &mdDataSum );
  1811.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1812.     
  1813.     MDxInit( &mdDataSum );
  1814.     MD4Translate( lpData, len, &mdDataSum );    
  1815.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1816.  
  1817.     return;
  1818. }
  1819.  
  1820.  
  1821. -------------- Include
  1822.  
  1823. #ifndef __windows_h__
  1824.         typedef unsigned long DWORD;
  1825.         #define STDCALL _stdcall
  1826. #endif
  1827.  
  1828. typedef struct 
  1829. {
  1830.     DWORD dwSum[4];
  1831. }MDxSum;
  1832.  
  1833. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1834. void STDCALL MDxInit( MDxSum * );
  1835. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1836. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1837. const char * STDCALL MDxGetVersion();
  1838. void STDCALL MDxFinalize( MDxSum * );
  1839.  
  1840.  
  1841.  
  1842.  
  1843. #include "mdx.h"
  1844. #include <stdlib.h>
  1845. #include <stdio.h>
  1846. #include <string.h>
  1847.  
  1848. // READLEN % 64 must = 0
  1849. #define READLEN    1048576L // 2^20, 1MB
  1850.  
  1851. void DigestFile( char * );
  1852. void DigestString();
  1853.  
  1854. void main(int argc, char *argv[])
  1855. {
  1856.     printf("%s\n\n", MDxGetVersion());
  1857.  
  1858.     if( argc > 1 )
  1859.         DigestFile( argv[1] );
  1860.     else    
  1861.         DigestString();
  1862.  
  1863. }
  1864.  
  1865. /*
  1866.     I use the 'chunk' method for processing files not because of
  1867.     limitations of my dll, but think what would happen if you
  1868.     tried to load an entire cd image into memory.
  1869. */
  1870. void DigestFile( char *szFName )
  1871. {
  1872.     FILE *file;
  1873.     void *lpData;
  1874.     long flen, mlen;
  1875.     MDxSum mdDataSum;
  1876.     MDxSum md4DataSum;
  1877.  
  1878.     // the 64 is for padding purposes
  1879.     lpData = malloc( READLEN + 64 );
  1880.     
  1881.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  1882.  
  1883.     file = fopen( szFName, "rb" );
  1884.     if( file == NULL )
  1885.     {
  1886.         printf("ERROR: File not found.\n");
  1887.         return;
  1888.     }
  1889.     
  1890.     MDxInit( &mdDataSum );
  1891.     MDxInit( &md4DataSum );
  1892.     
  1893.     fseek( file, 0, SEEK_END );
  1894.     //Get the file length
  1895.     flen = mlen = ftell( file );
  1896.     fseek( file, 0, SEEK_SET );
  1897.     
  1898.     // When it takes a while to process a large file,
  1899.     // remember that for each chunk it has to run 
  1900.     // through the main translation loop 16384 times!
  1901.         
  1902.     printf("Processing %ld byte file: .", flen );
  1903.     
  1904.     while( flen > READLEN )
  1905.     {
  1906.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  1907.         {
  1908.             printf("READ ERROR!\n");
  1909.             return;
  1910.         }
  1911.         MD5Translate( lpData, READLEN, &mdDataSum );
  1912.         MD4Translate( lpData, READLEN, &md4DataSum );
  1913.         flen -= READLEN;
  1914.         printf(".");
  1915.     }
  1916.  
  1917.     if (fread( lpData, 1, flen, file ) != flen)
  1918.     {
  1919.         printf("READ ERROR!\n");
  1920.         return;
  1921.     }
  1922.     // This is why I added the new argument to MDxPad
  1923.     // So we can pass the length of the data AND the
  1924.     // Total length of the message
  1925.     // Also it now returns the # of padding bytes added,
  1926.     // this is for files that are an exact multiple of the chunk
  1927.     // length. (Otherwise the padding isn't Translated)
  1928.     flen += MDxPad( lpData, flen, mlen );
  1929.     MD5Translate( lpData, flen, &mdDataSum );    
  1930.     MD4Translate( lpData, flen, &md4DataSum );
  1931.  
  1932.     // New step necessary because of the 'chunking' method
  1933.     MDxFinalize( &mdDataSum );
  1934.     MDxFinalize( &md4DataSum );
  1935.     
  1936.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  1937.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1938.     fclose(file);
  1939.         
  1940. }
  1941.  
  1942. void DigestString()
  1943. {
  1944.     
  1945.     //For our demo purposes, no strings bigger than 1024 :)
  1946.     unsigned char lpData[1024] = "";
  1947.     long len = 0;
  1948.     MDxSum mdDataSum;
  1949.  
  1950.     printf("Enter the string to digest: ");
  1951.     scanf("%s", &lpData );
  1952.     len = strlen(lpData);
  1953.     
  1954.     // Have to do this before the Padding...well...it's best anyway;)
  1955.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  1956.     
  1957.     // For the strings, we're gonna pad and digest the string
  1958.     // in one pass.
  1959.     MDxInit( &mdDataSum );
  1960.     MDxPad( lpData, len, len );
  1961.     
  1962.     MD5Translate( lpData, len, &mdDataSum );
  1963.         // New step necessary because of the 'chunking' method
  1964.         MDxFinalize( &mdDataSum );
  1965.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1966.     
  1967.     MDxInit( &mdDataSum );
  1968.     MD4Translate( lpData, len, &mdDataSum );    
  1969.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  1970.  
  1971.     return;
  1972. }
  1973.  
  1974.  
  1975. -------------- Include
  1976.  
  1977. #ifndef __windows_h__
  1978.         typedef unsigned long DWORD;
  1979.         #define STDCALL _stdcall
  1980. #endif
  1981.  
  1982. typedef struct 
  1983. {
  1984.     DWORD dwSum[4];
  1985. }MDxSum;
  1986.  
  1987. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  1988. void STDCALL MDxInit( MDxSum * );
  1989. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  1990. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  1991. const char * STDCALL MDxGetVersion();
  1992. void STDCALL MDxFinalize( MDxSum * );
  1993.  
  1994.  
  1995.  
  1996. #include "mdx.h"
  1997. #include <stdlib.h>
  1998. #include <stdio.h>
  1999. #include <string.h>
  2000.  
  2001. // READLEN % 64 must = 0
  2002. #define READLEN    1048576L // 2^20, 1MB
  2003.  
  2004. void DigestFile( char * );
  2005. void DigestString();
  2006.  
  2007. void main(int argc, char *argv[])
  2008. {
  2009.     printf("%s\n\n", MDxGetVersion());
  2010.  
  2011.     if( argc > 1 )
  2012.         DigestFile( argv[1] );
  2013.     else    
  2014.         DigestString();
  2015.  
  2016. }
  2017.  
  2018. /*
  2019.     I use the 'chunk' method for processing files not because of
  2020.     limitations of my dll, but think what would happen if you
  2021.     tried to load an entire cd image into memory.
  2022. */
  2023. void DigestFile( char *szFName )
  2024. {
  2025.     FILE *file;
  2026.     void *lpData;
  2027.     long flen, mlen;
  2028.     MDxSum mdDataSum;
  2029.     MDxSum md4DataSum;
  2030.  
  2031.     // the 64 is for padding purposes
  2032.     lpData = malloc( READLEN + 64 );
  2033.     
  2034.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2035.  
  2036.     file = fopen( szFName, "rb" );
  2037.     if( file == NULL )
  2038.     {
  2039.         printf("ERROR: File not found.\n");
  2040.         return;
  2041.     }
  2042.     
  2043.     MDxInit( &mdDataSum );
  2044.     MDxInit( &md4DataSum );
  2045.     
  2046.     fseek( file, 0, SEEK_END );
  2047.     //Get the file length
  2048.     flen = mlen = ftell( file );
  2049.     fseek( file, 0, SEEK_SET );
  2050.     
  2051.     // When it takes a while to process a large file,
  2052.     // remember that for each chunk it has to run 
  2053.     // through the main translation loop 16384 times!
  2054.         
  2055.     printf("Processing %ld byte file: .", flen );
  2056.     
  2057.     while( flen > READLEN )
  2058.     {
  2059.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2060.         {
  2061.             printf("READ ERROR!\n");
  2062.             return;
  2063.         }
  2064.         MD5Translate( lpData, READLEN, &mdDataSum );
  2065.         MD4Translate( lpData, READLEN, &md4DataSum );
  2066.         flen -= READLEN;
  2067.         printf(".");
  2068.     }
  2069.  
  2070.     if (fread( lpData, 1, flen, file ) != flen)
  2071.     {
  2072.         printf("READ ERROR!\n");
  2073.         return;
  2074.     }
  2075.     // This is why I added the new argument to MDxPad
  2076.     // So we can pass the length of the data AND the
  2077.     // Total length of the message
  2078.     // Also it now returns the # of padding bytes added,
  2079.     // this is for files that are an exact multiple of the chunk
  2080.     // length. (Otherwise the padding isn't Translated)
  2081.     flen += MDxPad( lpData, flen, mlen );
  2082.     MD5Translate( lpData, flen, &mdDataSum );    
  2083.     MD4Translate( lpData, flen, &md4DataSum );
  2084.  
  2085.     // New step necessary because of the 'chunking' method
  2086.     MDxFinalize( &mdDataSum );
  2087.     MDxFinalize( &md4DataSum );
  2088.     
  2089.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  2090.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2091.     fclose(file);
  2092.         
  2093. }
  2094.  
  2095. void DigestString()
  2096. {
  2097.     
  2098.     //For our demo purposes, no strings bigger than 1024 :)
  2099.     unsigned char lpData[1024] = "";
  2100.     long len = 0;
  2101.     MDxSum mdDataSum;
  2102.  
  2103.     printf("Enter the string to digest: ");
  2104.     scanf("%s", &lpData );
  2105.     len = strlen(lpData);
  2106.     
  2107.     // Have to do this before the Padding...well...it's best anyway;)
  2108.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  2109.     
  2110.     // For the strings, we're gonna pad and digest the string
  2111.     // in one pass.
  2112.     MDxInit( &mdDataSum );
  2113.     MDxPad( lpData, len, len );
  2114.     
  2115.     MD5Translate( lpData, len, &mdDataSum );
  2116.         // New step necessary because of the 'chunking' method
  2117.         MDxFinalize( &mdDataSum );
  2118.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2119.     
  2120.     MDxInit( &mdDataSum );
  2121.     MD4Translate( lpData, len, &mdDataSum );    
  2122.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2123.  
  2124.     return;
  2125. }
  2126.  
  2127.  
  2128. -------------- Include
  2129.  
  2130. #ifndef __windows_h__
  2131.         typedef unsigned long DWORD;
  2132.         #define STDCALL _stdcall
  2133. #endif
  2134.  
  2135. typedef struct 
  2136. {
  2137.     DWORD dwSum[4];
  2138. }MDxSum;
  2139.  
  2140. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  2141. void STDCALL MDxInit( MDxSum * );
  2142. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  2143. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  2144. const char * STDCALL MDxGetVersion();
  2145. void STDCALL MDxFinalize( MDxSum * );
  2146.  
  2147.  
  2148.  
  2149. #include "mdx.h"
  2150. #include <stdlib.h>
  2151. #include <stdio.h>
  2152. #include <string.h>
  2153.  
  2154. // READLEN % 64 must = 0
  2155. #define READLEN    1048576L // 2^20, 1MB
  2156.  
  2157. void DigestFile( char * );
  2158. void DigestString();
  2159.  
  2160. void main(int argc, char *argv[])
  2161. {
  2162.     printf("%s\n\n", MDxGetVersion());
  2163.  
  2164.     if( argc > 1 )
  2165.         DigestFile( argv[1] );
  2166.     else    
  2167.         DigestString();
  2168.  
  2169. }
  2170.  
  2171. /*
  2172.     I use the 'chunk' method for processing files not because of
  2173.     limitations of my dll, but think what would happen if you
  2174.     tried to load an entire cd image into memory.
  2175. */
  2176. void DigestFile( char *szFName )
  2177. {
  2178.     FILE *file;
  2179.     void *lpData;
  2180.     long flen, mlen;
  2181.     MDxSum mdDataSum;
  2182.     MDxSum md4DataSum;
  2183.  
  2184.     // the 64 is for padding purposes
  2185.     lpData = malloc( READLEN + 64 );
  2186.     
  2187.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2188.  
  2189.     file = fopen( szFName, "rb" );
  2190.     if( file == NULL )
  2191.     {
  2192.         printf("ERROR: File not found.\n");
  2193.         return;
  2194.     }
  2195.     
  2196.     MDxInit( &mdDataSum );
  2197.     MDxInit( &md4DataSum );
  2198.     
  2199.     fseek( file, 0, SEEK_END );
  2200.     //Get the file length
  2201.     flen = mlen = ftell( file );
  2202.     fseek( file, 0, SEEK_SET );
  2203.     
  2204.     // When it takes a while to process a large file,
  2205.     // remember that for each chunk it has to run 
  2206.     // through the main translation loop 16384 times!
  2207.         
  2208.     printf("Processing %ld byte file: .", flen );
  2209.     
  2210.     while( flen > READLEN )
  2211.     {
  2212.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2213.         {
  2214.             printf("READ ERROR!\n");
  2215.             return;
  2216.         }
  2217.         MD5Translate( lpData, READLEN, &mdDataSum );
  2218.         MD4Translate( lpData, READLEN, &md4DataSum );
  2219.         flen -= READLEN;
  2220.         printf(".");
  2221.     }
  2222.  
  2223.     if (fread( lpData, 1, flen, file ) != flen)
  2224.     {
  2225.         printf("READ ERROR!\n");
  2226.         return;
  2227.     }
  2228.     // This is why I added the new argument to MDxPad
  2229.     // So we can pass the length of the data AND the
  2230.     // Total length of the message
  2231.     // Also it now returns the # of padding bytes added,
  2232.     // this is for files that are an exact multiple of the chunk
  2233.     // length. (Otherwise the padding isn't Translated)
  2234.     flen += MDxPad( lpData, flen, mlen );
  2235.     MD5Translate( lpData, flen, &mdDataSum );    
  2236.     MD4Translate( lpData, flen, &md4DataSum );
  2237.  
  2238.     // New step necessary because of the 'chunking' method
  2239.     MDxFinalize( &mdDataSum );
  2240.     MDxFinalize( &md4DataSum );
  2241.     
  2242.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  2243.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2244.     fclose(file);
  2245.         
  2246. }
  2247.  
  2248. void DigestString()
  2249. {
  2250.     
  2251.     //For our demo purposes, no strings bigger than 1024 :)
  2252.     unsigned char lpData[1024] = "";
  2253.     long len = 0;
  2254.     MDxSum mdDataSum;
  2255.  
  2256.     printf("Enter the string to digest: ");
  2257.     scanf("%s", &lpData );
  2258.     len = strlen(lpData);
  2259.     
  2260.     // Have to do this before the Padding...well...it's best anyway;)
  2261.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  2262.     
  2263.     // For the strings, we're gonna pad and digest the string
  2264.     // in one pass.
  2265.     MDxInit( &mdDataSum );
  2266.     MDxPad( lpData, len, len );
  2267.     
  2268.     MD5Translate( lpData, len, &mdDataSum );
  2269.         // New step necessary because of the 'chunking' method
  2270.         MDxFinalize( &mdDataSum );
  2271.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2272.     
  2273.     MDxInit( &mdDataSum );
  2274.     MD4Translate( lpData, len, &mdDataSum );    
  2275.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2276.  
  2277.     return;
  2278. }
  2279.  
  2280.  
  2281. -------------- Include
  2282.  
  2283. #ifndef __windows_h__
  2284.         typedef unsigned long DWORD;
  2285.         #define STDCALL _stdcall
  2286. #endif
  2287.  
  2288. typedef struct 
  2289. {
  2290.     DWORD dwSum[4];
  2291. }MDxSum;
  2292.  
  2293. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  2294. void STDCALL MDxInit( MDxSum * );
  2295. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  2296. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  2297. const char * STDCALL MDxGetVersion();
  2298. void STDCALL MDxFinalize( MDxSum * );
  2299.  
  2300.  
  2301.  
  2302.  
  2303. #include "mdx.h"
  2304. #include <stdlib.h>
  2305. #include <stdio.h>
  2306. #include <string.h>
  2307.  
  2308. // READLEN % 64 must = 0
  2309. #define READLEN    1048576L // 2^20, 1MB
  2310.  
  2311. void DigestFile( char * );
  2312. void DigestString();
  2313.  
  2314. void main(int argc, char *argv[])
  2315. {
  2316.     printf("%s\n\n", MDxGetVersion());
  2317.  
  2318.     if( argc > 1 )
  2319.         DigestFile( argv[1] );
  2320.     else    
  2321.         DigestString();
  2322.  
  2323. }
  2324.  
  2325. /*
  2326.     I use the 'chunk' method for processing files not because of
  2327.     limitations of my dll, but think what would happen if you
  2328.     tried to load an entire cd image into memory.
  2329. */
  2330. void DigestFile( char *szFName )
  2331. {
  2332.     FILE *file;
  2333.     void *lpData;
  2334.     long flen, mlen;
  2335.     MDxSum mdDataSum;
  2336.     MDxSum md4DataSum;
  2337.  
  2338.     // the 64 is for padding purposes
  2339.     lpData = malloc( READLEN + 64 );
  2340.     
  2341.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2342.  
  2343.     file = fopen( szFName, "rb" );
  2344.     if( file == NULL )
  2345.     {
  2346.         printf("ERROR: File not found.\n");
  2347.         return;
  2348.     }
  2349.     
  2350.     MDxInit( &mdDataSum );
  2351.     MDxInit( &md4DataSum );
  2352.     
  2353.     fseek( file, 0, SEEK_END );
  2354.     //Get the file length
  2355.     flen = mlen = ftell( file );
  2356.     fseek( file, 0, SEEK_SET );
  2357.     
  2358.     // When it takes a while to process a large file,
  2359.     // remember that for each chunk it has to run 
  2360.     // through the main translation loop 16384 times!
  2361.         
  2362.     printf("Processing %ld byte file: .", flen );
  2363.     
  2364.     while( flen > READLEN )
  2365.     {
  2366.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2367.         {
  2368.             printf("READ ERROR!\n");
  2369.             return;
  2370.         }
  2371.         MD5Translate( lpData, READLEN, &mdDataSum );
  2372.         MD4Translate( lpData, READLEN, &md4DataSum );
  2373.         flen -= READLEN;
  2374.         printf(".");
  2375.     }
  2376.  
  2377.     if (fread( lpData, 1, flen, file ) != flen)
  2378.     {
  2379.         printf("READ ERROR!\n");
  2380.         return;
  2381.     }
  2382.     // This is why I added the new argument to MDxPad
  2383.     // So we can pass the length of the data AND the
  2384.     // Total length of the message
  2385.     // Also it now returns the # of padding bytes added,
  2386.     // this is for files that are an exact multiple of the chunk
  2387.     // length. (Otherwise the padding isn't Translated)
  2388.     flen += MDxPad( lpData, flen, mlen );
  2389.     MD5Translate( lpData, flen, &mdDataSum );    
  2390.     MD4Translate( lpData, flen, &md4DataSum );
  2391.  
  2392.     // New step necessary because of the 'chunking' method
  2393.     MDxFinalize( &mdDataSum );
  2394.     MDxFinalize( &md4DataSum );
  2395.     
  2396.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  2397.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2398.     fclose(file);
  2399.         
  2400. }
  2401.  
  2402. void DigestString()
  2403. {
  2404.     
  2405.     //For our demo purposes, no strings bigger than 1024 :)
  2406.     unsigned char lpData[1024] = "";
  2407.     long len = 0;
  2408.     MDxSum mdDataSum;
  2409.  
  2410.     printf("Enter the string to digest: ");
  2411.     scanf("%s", &lpData );
  2412.     len = strlen(lpData);
  2413.     
  2414.     // Have to do this before the Padding...well...it's best anyway;)
  2415.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  2416.     
  2417.     // For the strings, we're gonna pad and digest the string
  2418.     // in one pass.
  2419.     MDxInit( &mdDataSum );
  2420.     MDxPad( lpData, len, len );
  2421.     
  2422.     MD5Translate( lpData, len, &mdDataSum );
  2423.         // New step necessary because of the 'chunking' method
  2424.         MDxFinalize( &mdDataSum );
  2425.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2426.     
  2427.     MDxInit( &mdDataSum );
  2428.     MD4Translate( lpData, len, &mdDataSum );    
  2429.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2430.  
  2431.     return;
  2432. }
  2433.  
  2434.  
  2435. -------------- Include
  2436.  
  2437. #ifndef __windows_h__
  2438.         typedef unsigned long DWORD;
  2439.         #define STDCALL _stdcall
  2440. #endif
  2441.  
  2442. typedef struct 
  2443. {
  2444.     DWORD dwSum[4];
  2445. }MDxSum;
  2446.  
  2447. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  2448. void STDCALL MDxInit( MDxSum * );
  2449. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  2450. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  2451. const char * STDCALL MDxGetVersion();
  2452. void STDCALL MDxFinalize( MDxSum * );
  2453.  
  2454.  
  2455.  
  2456. #include "mdx.h"
  2457. #include <stdlib.h>
  2458. #include <stdio.h>
  2459. #include <string.h>
  2460.  
  2461. // READLEN % 64 must = 0
  2462. #define READLEN    1048576L // 2^20, 1MB
  2463.  
  2464. void DigestFile( char * );
  2465. void DigestString();
  2466.  
  2467. void main(int argc, char *argv[])
  2468. {
  2469.     printf("%s\n\n", MDxGetVersion());
  2470.  
  2471.     if( argc > 1 )
  2472.         DigestFile( argv[1] );
  2473.     else    
  2474.         DigestString();
  2475.  
  2476. }
  2477.  
  2478. /*
  2479.     I use the 'chunk' method for processing files not because of
  2480.     limitations of my dll, but think what would happen if you
  2481.     tried to load an entire cd image into memory.
  2482. */
  2483. void DigestFile( char *szFName )
  2484. {
  2485.     FILE *file;
  2486.     void *lpData;
  2487.     long flen, mlen;
  2488.     MDxSum mdDataSum;
  2489.     MDxSum md4DataSum;
  2490.  
  2491.     // the 64 is for padding purposes
  2492.     lpData = malloc( READLEN + 64 );
  2493.     
  2494.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2495.  
  2496.     file = fopen( szFName, "rb" );
  2497.     if( file == NULL )
  2498.     {
  2499.         printf("ERROR: File not found.\n");
  2500.         return;
  2501.     }
  2502.     
  2503.     MDxInit( &mdDataSum );
  2504.     MDxInit( &md4DataSum );
  2505.     
  2506.     fseek( file, 0, SEEK_END );
  2507.     //Get the file length
  2508.     flen = mlen = ftell( file );
  2509.     fseek( file, 0, SEEK_SET );
  2510.     
  2511.     // When it takes a while to process a large file,
  2512.     // remember that for each chunk it has to run 
  2513.     // through the main translation loop 16384 times!
  2514.         
  2515.     printf("Processing %ld byte file: .", flen );
  2516.     
  2517.     while( flen > READLEN )
  2518.     {
  2519.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2520.         {
  2521.             printf("READ ERROR!\n");
  2522.             return;
  2523.         }
  2524.         MD5Translate( lpData, READLEN, &mdDataSum );
  2525.         MD4Translate( lpData, READLEN, &md4DataSum );
  2526.         flen -= READLEN;
  2527.         printf(".");
  2528.     }
  2529.  
  2530.     if (fread( lpData, 1, flen, file ) != flen)
  2531.     {
  2532.         printf("READ ERROR!\n");
  2533.         return;
  2534.     }
  2535.     // This is why I added the new argument to MDxPad
  2536.     // So we can pass the length of the data AND the
  2537.     // Total length of the message
  2538.     // Also it now returns the # of padding bytes added,
  2539.     // this is for files that are an exact multiple of the chunk
  2540.     // length. (Otherwise the padding isn't Translated)
  2541.     flen += MDxPad( lpData, flen, mlen );
  2542.     MD5Translate( lpData, flen, &mdDataSum );    
  2543.     MD4Translate( lpData, flen, &md4DataSum );
  2544.  
  2545.     // New step necessary because of the 'chunking' method
  2546.     MDxFinalize( &mdDataSum );
  2547.     MDxFinalize( &md4DataSum );
  2548.     
  2549.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  2550.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2551.     fclose(file);
  2552.         
  2553. }
  2554.  
  2555. void DigestString()
  2556. {
  2557.     
  2558.     //For our demo purposes, no strings bigger than 1024 :)
  2559.     unsigned char lpData[1024] = "";
  2560.     long len = 0;
  2561.     MDxSum mdDataSum;
  2562.  
  2563.     printf("Enter the string to digest: ");
  2564.     scanf("%s", &lpData );
  2565.     len = strlen(lpData);
  2566.     
  2567.     // Have to do this before the Padding...well...it's best anyway;)
  2568.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  2569.     
  2570.     // For the strings, we're gonna pad and digest the string
  2571.     // in one pass.
  2572.     MDxInit( &mdDataSum );
  2573.     MDxPad( lpData, len, len );
  2574.     
  2575.     MD5Translate( lpData, len, &mdDataSum );
  2576.         // New step necessary because of the 'chunking' method
  2577.         MDxFinalize( &mdDataSum );
  2578.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2579.     
  2580.     MDxInit( &mdDataSum );
  2581.     MD4Translate( lpData, len, &mdDataSum );    
  2582.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2583.  
  2584.     return;
  2585. }
  2586.  
  2587.  
  2588. -------------- Include
  2589.  
  2590. #ifndef __windows_h__
  2591.         typedef unsigned long DWORD;
  2592.         #define STDCALL _stdcall
  2593. #endif
  2594.  
  2595. typedef struct 
  2596. {
  2597.     DWORD dwSum[4];
  2598. }MDxSum;
  2599.  
  2600. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  2601. void STDCALL MDxInit( MDxSum * );
  2602. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  2603. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  2604. const char * STDCALL MDxGetVersion();
  2605. void STDCALL MDxFinalize( MDxSum * );
  2606.  
  2607.  
  2608.  
  2609.  
  2610. #include "mdx.h"
  2611. #include <stdlib.h>
  2612. #include <stdio.h>
  2613. #include <string.h>
  2614.  
  2615. // READLEN % 64 must = 0
  2616. #define READLEN    1048576L // 2^20, 1MB
  2617.  
  2618. void DigestFile( char * );
  2619. void DigestString();
  2620.  
  2621. void main(int argc, char *argv[])
  2622. {
  2623.     printf("%s\n\n", MDxGetVersion());
  2624.  
  2625.     if( argc > 1 )
  2626.         DigestFile( argv[1] );
  2627.     else    
  2628.         DigestString();
  2629.  
  2630. }
  2631.  
  2632. /*
  2633.     I use the 'chunk' method for processing files not because of
  2634.     limitations of my dll, but think what would happen if you
  2635.     tried to load an entire cd image into memory.
  2636. */
  2637. void DigestFile( char *szFName )
  2638. {
  2639.     FILE *file;
  2640.     void *lpData;
  2641.     long flen, mlen;
  2642.     MDxSum mdDataSum;
  2643.     MDxSum md4DataSum;
  2644.  
  2645.     // the 64 is for padding purposes
  2646.     lpData = malloc( READLEN + 64 );
  2647.     
  2648.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2649.  
  2650.     file = fopen( szFName, "rb" );
  2651.     if( file == NULL )
  2652.     {
  2653.         printf("ERROR: File not found.\n");
  2654.         return;
  2655.     }
  2656.     
  2657.     MDxInit( &mdDataSum );
  2658.     MDxInit( &md4DataSum );
  2659.     
  2660.     fseek( file, 0, SEEK_END );
  2661.     //Get the file length
  2662.     flen = mlen = ftell( file );
  2663.     fseek( file, 0, SEEK_SET );
  2664.     
  2665.     // When it takes a while to process a large file,
  2666.     // remember that for each chunk it has to run 
  2667.     // through the main translation loop 16384 times!
  2668.         
  2669.     printf("Processing %ld byte file: .", flen );
  2670.     
  2671.     while( flen > READLEN )
  2672.     {
  2673.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2674.         {
  2675.             printf("READ ERROR!\n");
  2676.             return;
  2677.         }
  2678.         MD5Translate( lpData, READLEN, &mdDataSum );
  2679.         MD4Translate( lpData, READLEN, &md4DataSum );
  2680.         flen -= READLEN;
  2681.         printf(".");
  2682.     }
  2683.  
  2684.     if (fread( lpData, 1, flen, file ) != flen)
  2685.     {
  2686.         printf("READ ERROR!\n");
  2687.         return;
  2688.     }
  2689.     // This is why I added the new argument to MDxPad
  2690.     // So we can pass the length of the data AND the
  2691.     // Total length of the message
  2692.     // Also it now returns the # of padding bytes added,
  2693.     // this is for files that are an exact multiple of the chunk
  2694.     // length. (Otherwise the padding isn't Translated)
  2695.     flen += MDxPad( lpData, flen, mlen );
  2696.     MD5Translate( lpData, flen, &mdDataSum );    
  2697.     MD4Translate( lpData, flen, &md4DataSum );
  2698.  
  2699.     // New step necessary because of the 'chunking' method
  2700.     MDxFinalize( &mdDataSum );
  2701.     MDxFinalize( &md4DataSum );
  2702.     
  2703.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  2704.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2705.     fclose(file);
  2706.         
  2707. }
  2708.  
  2709. void DigestString()
  2710. {
  2711.     
  2712.     //For our demo purposes, no strings bigger than 1024 :)
  2713.     unsigned char lpData[1024] = "";
  2714.     long len = 0;
  2715.     MDxSum mdDataSum;
  2716.  
  2717.     printf("Enter the string to digest: ");
  2718.     scanf("%s", &lpData );
  2719.     len = strlen(lpData);
  2720.     
  2721.     // Have to do this before the Padding...well...it's best anyway;)
  2722.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  2723.     
  2724.     // For the strings, we're gonna pad and digest the string
  2725.     // in one pass.
  2726.     MDxInit( &mdDataSum );
  2727.     MDxPad( lpData, len, len );
  2728.     
  2729.     MD5Translate( lpData, len, &mdDataSum );
  2730.         // New step necessary because of the 'chunking' method
  2731.         MDxFinalize( &mdDataSum );
  2732.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2733.     
  2734.     MDxInit( &mdDataSum );
  2735.     MD4Translate( lpData, len, &mdDataSum );    
  2736.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2737.  
  2738.     return;
  2739. }
  2740.  
  2741.  
  2742. -------------- Include
  2743.  
  2744. #ifndef __windows_h__
  2745.         typedef unsigned long DWORD;
  2746.         #define STDCALL _stdcall
  2747. #endif
  2748.  
  2749. typedef struct 
  2750. {
  2751.     DWORD dwSum[4];
  2752. }MDxSum;
  2753.  
  2754. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  2755. void STDCALL MDxInit( MDxSum * );
  2756. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  2757. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  2758. const char * STDCALL MDxGetVersion();
  2759. void STDCALL MDxFinalize( MDxSum * );
  2760.  
  2761.  
  2762.  
  2763.  
  2764. #include "mdx.h"
  2765. #include <stdlib.h>
  2766. #include <stdio.h>
  2767. #include <string.h>
  2768.  
  2769. // READLEN % 64 must = 0
  2770. #define READLEN    1048576L // 2^20, 1MB
  2771.  
  2772. void DigestFile( char * );
  2773. void DigestString();
  2774.  
  2775. void main(int argc, char *argv[])
  2776. {
  2777.     printf("%s\n\n", MDxGetVersion());
  2778.  
  2779.     if( argc > 1 )
  2780.         DigestFile( argv[1] );
  2781.     else    
  2782.         DigestString();
  2783.  
  2784. }
  2785.  
  2786. /*
  2787.     I use the 'chunk' method for processing files not because of
  2788.     limitations of my dll, but think what would happen if you
  2789.     tried to load an entire cd image into memory.
  2790. */
  2791. void DigestFile( char *szFName )
  2792. {
  2793.     FILE *file;
  2794.     void *lpData;
  2795.     long flen, mlen;
  2796.     MDxSum mdDataSum;
  2797.     MDxSum md4DataSum;
  2798.  
  2799.     // the 64 is for padding purposes
  2800.     lpData = malloc( READLEN + 64 );
  2801.     
  2802.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2803.  
  2804.     file = fopen( szFName, "rb" );
  2805.     if( file == NULL )
  2806.     {
  2807.         printf("ERROR: File not found.\n");
  2808.         return;
  2809.     }
  2810.     
  2811.     MDxInit( &mdDataSum );
  2812.     MDxInit( &md4DataSum );
  2813.     
  2814.     fseek( file, 0, SEEK_END );
  2815.     //Get the file length
  2816.     flen = mlen = ftell( file );
  2817.     fseek( file, 0, SEEK_SET );
  2818.     
  2819.     // When it takes a while to process a large file,
  2820.     // remember that for each chunk it has to run 
  2821.     // through the main translation loop 16384 times!
  2822.         
  2823.     printf("Processing %ld byte file: .", flen );
  2824.     
  2825.     while( flen > READLEN )
  2826.     {
  2827.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2828.         {
  2829.             printf("READ ERROR!\n");
  2830.             return;
  2831.         }
  2832.         MD5Translate( lpData, READLEN, &mdDataSum );
  2833.         MD4Translate( lpData, READLEN, &md4DataSum );
  2834.         flen -= READLEN;
  2835.         printf(".");
  2836.     }
  2837.  
  2838.     if (fread( lpData, 1, flen, file ) != flen)
  2839.     {
  2840.         printf("READ ERROR!\n");
  2841.         return;
  2842.     }
  2843.     // This is why I added the new argument to MDxPad
  2844.     // So we can pass the length of the data AND the
  2845.     // Total length of the message
  2846.     // Also it now returns the # of padding bytes added,
  2847.     // this is for files that are an exact multiple of the chunk
  2848.     // length. (Otherwise the padding isn't Translated)
  2849.     flen += MDxPad( lpData, flen, mlen );
  2850.     MD5Translate( lpData, flen, &mdDataSum );    
  2851.     MD4Translate( lpData, flen, &md4DataSum );
  2852.  
  2853.     // New step necessary because of the 'chunking' method
  2854.     MDxFinalize( &mdDataSum );
  2855.     MDxFinalize( &md4DataSum );
  2856.     
  2857.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  2858.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2859.     fclose(file);
  2860.         
  2861. }
  2862.  
  2863. void DigestString()
  2864. {
  2865.     
  2866.     //For our demo purposes, no strings bigger than 1024 :)
  2867.     unsigned char lpData[1024] = "";
  2868.     long len = 0;
  2869.     MDxSum mdDataSum;
  2870.  
  2871.     printf("Enter the string to digest: ");
  2872.     scanf("%s", &lpData );
  2873.     len = strlen(lpData);
  2874.     
  2875.     // Have to do this before the Padding...well...it's best anyway;)
  2876.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  2877.     
  2878.     // For the strings, we're gonna pad and digest the string
  2879.     // in one pass.
  2880.     MDxInit( &mdDataSum );
  2881.     MDxPad( lpData, len, len );
  2882.     
  2883.     MD5Translate( lpData, len, &mdDataSum );
  2884.         // New step necessary because of the 'chunking' method
  2885.         MDxFinalize( &mdDataSum );
  2886.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2887.     
  2888.     MDxInit( &mdDataSum );
  2889.     MD4Translate( lpData, len, &mdDataSum );    
  2890.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  2891.  
  2892.     return;
  2893. }
  2894.  
  2895.  
  2896. -------------- Include
  2897.  
  2898. #ifndef __windows_h__
  2899.         typedef unsigned long DWORD;
  2900.         #define STDCALL _stdcall
  2901. #endif
  2902.  
  2903. typedef struct 
  2904. {
  2905.     DWORD dwSum[4];
  2906. }MDxSum;
  2907.  
  2908. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  2909. void STDCALL MDxInit( MDxSum * );
  2910. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  2911. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  2912. const char * STDCALL MDxGetVersion();
  2913. void STDCALL MDxFinalize( MDxSum * );
  2914.  
  2915.  
  2916.  
  2917. #include "mdx.h"
  2918. #include <stdlib.h>
  2919. #include <stdio.h>
  2920. #include <string.h>
  2921.  
  2922. // READLEN % 64 must = 0
  2923. #define READLEN    1048576L // 2^20, 1MB
  2924.  
  2925. void DigestFile( char * );
  2926. void DigestString();
  2927.  
  2928. void main(int argc, char *argv[])
  2929. {
  2930.     printf("%s\n\n", MDxGetVersion());
  2931.  
  2932.     if( argc > 1 )
  2933.         DigestFile( argv[1] );
  2934.     else    
  2935.         DigestString();
  2936.  
  2937. }
  2938.  
  2939. /*
  2940.     I use the 'chunk' method for processing files not because of
  2941.     limitations of my dll, but think what would happen if you
  2942.     tried to load an entire cd image into memory.
  2943. */
  2944. void DigestFile( char *szFName )
  2945. {
  2946.     FILE *file;
  2947.     void *lpData;
  2948.     long flen, mlen;
  2949.     MDxSum mdDataSum;
  2950.     MDxSum md4DataSum;
  2951.  
  2952.     // the 64 is for padding purposes
  2953.     lpData = malloc( READLEN + 64 );
  2954.     
  2955.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  2956.  
  2957.     file = fopen( szFName, "rb" );
  2958.     if( file == NULL )
  2959.     {
  2960.         printf("ERROR: File not found.\n");
  2961.         return;
  2962.     }
  2963.     
  2964.     MDxInit( &mdDataSum );
  2965.     MDxInit( &md4DataSum );
  2966.     
  2967.     fseek( file, 0, SEEK_END );
  2968.     //Get the file length
  2969.     flen = mlen = ftell( file );
  2970.     fseek( file, 0, SEEK_SET );
  2971.     
  2972.     // When it takes a while to process a large file,
  2973.     // remember that for each chunk it has to run 
  2974.     // through the main translation loop 16384 times!
  2975.         
  2976.     printf("Processing %ld byte file: .", flen );
  2977.     
  2978.     while( flen > READLEN )
  2979.     {
  2980.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  2981.         {
  2982.             printf("READ ERROR!\n");
  2983.             return;
  2984.         }
  2985.         MD5Translate( lpData, READLEN, &mdDataSum );
  2986.         MD4Translate( lpData, READLEN, &md4DataSum );
  2987.         flen -= READLEN;
  2988.         printf(".");
  2989.     }
  2990.  
  2991.     if (fread( lpData, 1, flen, file ) != flen)
  2992.     {
  2993.         printf("READ ERROR!\n");
  2994.         return;
  2995.     }
  2996.     // This is why I added the new argument to MDxPad
  2997.     // So we can pass the length of the data AND the
  2998.     // Total length of the message
  2999.     // Also it now returns the # of padding bytes added,
  3000.     // this is for files that are an exact multiple of the chunk
  3001.     // length. (Otherwise the padding isn't Translated)
  3002.     flen += MDxPad( lpData, flen, mlen );
  3003.     MD5Translate( lpData, flen, &mdDataSum );    
  3004.     MD4Translate( lpData, flen, &md4DataSum );
  3005.  
  3006.     // New step necessary because of the 'chunking' method
  3007.     MDxFinalize( &mdDataSum );
  3008.     MDxFinalize( &md4DataSum );
  3009.     
  3010.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3011.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3012.     fclose(file);
  3013.         
  3014. }
  3015.  
  3016. void DigestString()
  3017. {
  3018.     
  3019.     //For our demo purposes, no strings bigger than 1024 :)
  3020.     unsigned char lpData[1024] = "";
  3021.     long len = 0;
  3022.     MDxSum mdDataSum;
  3023.  
  3024.     printf("Enter the string to digest: ");
  3025.     scanf("%s", &lpData );
  3026.     len = strlen(lpData);
  3027.     
  3028.     // Have to do this before the Padding...well...it's best anyway;)
  3029.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3030.     
  3031.     // For the strings, we're gonna pad and digest the string
  3032.     // in one pass.
  3033.     MDxInit( &mdDataSum );
  3034.     MDxPad( lpData, len, len );
  3035.     
  3036.     MD5Translate( lpData, len, &mdDataSum );
  3037.         // New step necessary because of the 'chunking' method
  3038.         MDxFinalize( &mdDataSum );
  3039.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3040.     
  3041.     MDxInit( &mdDataSum );
  3042.     MD4Translate( lpData, len, &mdDataSum );    
  3043.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3044.  
  3045.     return;
  3046. }
  3047.  
  3048.  
  3049. -------------- Include
  3050.  
  3051. #ifndef __windows_h__
  3052.         typedef unsigned long DWORD;
  3053.         #define STDCALL _stdcall
  3054. #endif
  3055.  
  3056. typedef struct 
  3057. {
  3058.     DWORD dwSum[4];
  3059. }MDxSum;
  3060.  
  3061. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3062. void STDCALL MDxInit( MDxSum * );
  3063. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3064. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3065. const char * STDCALL MDxGetVersion();
  3066. void STDCALL MDxFinalize( MDxSum * );
  3067.  
  3068.  
  3069. #include "mdx.h"
  3070. #include <stdlib.h>
  3071. #include <stdio.h>
  3072. #include <string.h>
  3073.  
  3074. // READLEN % 64 must = 0
  3075. #define READLEN    1048576L // 2^20, 1MB
  3076.  
  3077. void DigestFile( char * );
  3078. void DigestString();
  3079.  
  3080. void main(int argc, char *argv[])
  3081. {
  3082.     printf("%s\n\n", MDxGetVersion());
  3083.  
  3084.     if( argc > 1 )
  3085.         DigestFile( argv[1] );
  3086.     else    
  3087.         DigestString();
  3088.  
  3089. }
  3090.  
  3091. /*
  3092.     I use the 'chunk' method for processing files not because of
  3093.     limitations of my dll, but think what would happen if you
  3094.     tried to load an entire cd image into memory.
  3095. */
  3096. void DigestFile( char *szFName )
  3097. {
  3098.     FILE *file;
  3099.     void *lpData;
  3100.     long flen, mlen;
  3101.     MDxSum mdDataSum;
  3102.     MDxSum md4DataSum;
  3103.  
  3104.     // the 64 is for padding purposes
  3105.     lpData = malloc( READLEN + 64 );
  3106.     
  3107.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  3108.  
  3109.     file = fopen( szFName, "rb" );
  3110.     if( file == NULL )
  3111.     {
  3112.         printf("ERROR: File not found.\n");
  3113.         return;
  3114.     }
  3115.     
  3116.     MDxInit( &mdDataSum );
  3117.     MDxInit( &md4DataSum );
  3118.     
  3119.     fseek( file, 0, SEEK_END );
  3120.     //Get the file length
  3121.     flen = mlen = ftell( file );
  3122.     fseek( file, 0, SEEK_SET );
  3123.     
  3124.     // When it takes a while to process a large file,
  3125.     // remember that for each chunk it has to run 
  3126.     // through the main translation loop 16384 times!
  3127.         
  3128.     printf("Processing %ld byte file: .", flen );
  3129.     
  3130.     while( flen > READLEN )
  3131.     {
  3132.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  3133.         {
  3134.             printf("READ ERROR!\n");
  3135.             return;
  3136.         }
  3137.         MD5Translate( lpData, READLEN, &mdDataSum );
  3138.         MD4Translate( lpData, READLEN, &md4DataSum );
  3139.         flen -= READLEN;
  3140.         printf(".");
  3141.     }
  3142.  
  3143.     if (fread( lpData, 1, flen, file ) != flen)
  3144.     {
  3145.         printf("READ ERROR!\n");
  3146.         return;
  3147.     }
  3148.     // This is why I added the new argument to MDxPad
  3149.     // So we can pass the length of the data AND the
  3150.     // Total length of the message
  3151.     // Also it now returns the # of padding bytes added,
  3152.     // this is for files that are an exact multiple of the chunk
  3153.     // length. (Otherwise the padding isn't Translated)
  3154.     flen += MDxPad( lpData, flen, mlen );
  3155.     MD5Translate( lpData, flen, &mdDataSum );    
  3156.     MD4Translate( lpData, flen, &md4DataSum );
  3157.  
  3158.     // New step necessary because of the 'chunking' method
  3159.     MDxFinalize( &mdDataSum );
  3160.     MDxFinalize( &md4DataSum );
  3161.     
  3162.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3163.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3164.     fclose(file);
  3165.         
  3166. }
  3167.  
  3168. void DigestString()
  3169. {
  3170.     
  3171.     //For our demo purposes, no strings bigger than 1024 :)
  3172.     unsigned char lpData[1024] = "";
  3173.     long len = 0;
  3174.     MDxSum mdDataSum;
  3175.  
  3176.     printf("Enter the string to digest: ");
  3177.     scanf("%s", &lpData );
  3178.     len = strlen(lpData);
  3179.     
  3180.     // Have to do this before the Padding...well...it's best anyway;)
  3181.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3182.     
  3183.     // For the strings, we're gonna pad and digest the string
  3184.     // in one pass.
  3185.     MDxInit( &mdDataSum );
  3186.     MDxPad( lpData, len, len );
  3187.     
  3188.     MD5Translate( lpData, len, &mdDataSum );
  3189.         // New step necessary because of the 'chunking' method
  3190.         MDxFinalize( &mdDataSum );
  3191.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3192.     
  3193.     MDxInit( &mdDataSum );
  3194.     MD4Translate( lpData, len, &mdDataSum );    
  3195.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3196.  
  3197.     return;
  3198. }
  3199.  
  3200.  
  3201. -------------- Include
  3202.  
  3203. #ifndef __windows_h__
  3204.         typedef unsigned long DWORD;
  3205.         #define STDCALL _stdcall
  3206. #endif
  3207.  
  3208. typedef struct 
  3209. {
  3210.     DWORD dwSum[4];
  3211. }MDxSum;
  3212.  
  3213. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3214. void STDCALL MDxInit( MDxSum * );
  3215. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3216. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3217. const char * STDCALL MDxGetVersion();
  3218. void STDCALL MDxFinalize( MDxSum * );
  3219.  
  3220.  
  3221.  
  3222. #include "mdx.h"
  3223. #include <stdlib.h>
  3224. #include <stdio.h>
  3225. #include <string.h>
  3226.  
  3227. // READLEN % 64 must = 0
  3228. #define READLEN    1048576L // 2^20, 1MB
  3229.  
  3230. void DigestFile( char * );
  3231. void DigestString();
  3232.  
  3233. void main(int argc, char *argv[])
  3234. {
  3235.     printf("%s\n\n", MDxGetVersion());
  3236.  
  3237.     if( argc > 1 )
  3238.         DigestFile( argv[1] );
  3239.     else    
  3240.         DigestString();
  3241.  
  3242. }
  3243.  
  3244. /*
  3245.     I use the 'chunk' method for processing files not because of
  3246.     limitations of my dll, but think what would happen if you
  3247.     tried to load an entire cd image into memory.
  3248. */
  3249. void DigestFile( char *szFName )
  3250. {
  3251.     FILE *file;
  3252.     void *lpData;
  3253.     long flen, mlen;
  3254.     MDxSum mdDataSum;
  3255.     MDxSum md4DataSum;
  3256.  
  3257.     // the 64 is for padding purposes
  3258.     lpData = malloc( READLEN + 64 );
  3259.     
  3260.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  3261.  
  3262.     file = fopen( szFName, "rb" );
  3263.     if( file == NULL )
  3264.     {
  3265.         printf("ERROR: File not found.\n");
  3266.         return;
  3267.     }
  3268.     
  3269.     MDxInit( &mdDataSum );
  3270.     MDxInit( &md4DataSum );
  3271.     
  3272.     fseek( file, 0, SEEK_END );
  3273.     //Get the file length
  3274.     flen = mlen = ftell( file );
  3275.     fseek( file, 0, SEEK_SET );
  3276.     
  3277.     // When it takes a while to process a large file,
  3278.     // remember that for each chunk it has to run 
  3279.     // through the main translation loop 16384 times!
  3280.         
  3281.     printf("Processing %ld byte file: .", flen );
  3282.     
  3283.     while( flen > READLEN )
  3284.     {
  3285.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  3286.         {
  3287.             printf("READ ERROR!\n");
  3288.             return;
  3289.         }
  3290.         MD5Translate( lpData, READLEN, &mdDataSum );
  3291.         MD4Translate( lpData, READLEN, &md4DataSum );
  3292.         flen -= READLEN;
  3293.         printf(".");
  3294.     }
  3295.  
  3296.     if (fread( lpData, 1, flen, file ) != flen)
  3297.     {
  3298.         printf("READ ERROR!\n");
  3299.         return;
  3300.     }
  3301.     // This is why I added the new argument to MDxPad
  3302.     // So we can pass the length of the data AND the
  3303.     // Total length of the message
  3304.     // Also it now returns the # of padding bytes added,
  3305.     // this is for files that are an exact multiple of the chunk
  3306.     // length. (Otherwise the padding isn't Translated)
  3307.     flen += MDxPad( lpData, flen, mlen );
  3308.     MD5Translate( lpData, flen, &mdDataSum );    
  3309.     MD4Translate( lpData, flen, &md4DataSum );
  3310.  
  3311.     // New step necessary because of the 'chunking' method
  3312.     MDxFinalize( &mdDataSum );
  3313.     MDxFinalize( &md4DataSum );
  3314.     
  3315.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3316.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3317.     fclose(file);
  3318.         
  3319. }
  3320.  
  3321. void DigestString()
  3322. {
  3323.     
  3324.     //For our demo purposes, no strings bigger than 1024 :)
  3325.     unsigned char lpData[1024] = "";
  3326.     long len = 0;
  3327.     MDxSum mdDataSum;
  3328.  
  3329.     printf("Enter the string to digest: ");
  3330.     scanf("%s", &lpData );
  3331.     len = strlen(lpData);
  3332.     
  3333.     // Have to do this before the Padding...well...it's best anyway;)
  3334.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3335.     
  3336.     // For the strings, we're gonna pad and digest the string
  3337.     // in one pass.
  3338.     MDxInit( &mdDataSum );
  3339.     MDxPad( lpData, len, len );
  3340.     
  3341.     MD5Translate( lpData, len, &mdDataSum );
  3342.         // New step necessary because of the 'chunking' method
  3343.         MDxFinalize( &mdDataSum );
  3344.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3345.     
  3346.     MDxInit( &mdDataSum );
  3347.     MD4Translate( lpData, len, &mdDataSum );    
  3348.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3349.  
  3350.     return;
  3351. }
  3352.  
  3353.  
  3354. -------------- Include
  3355.  
  3356. #ifndef __windows_h__
  3357.         typedef unsigned long DWORD;
  3358.         #define STDCALL _stdcall
  3359. #endif
  3360.  
  3361. typedef struct 
  3362. {
  3363.     DWORD dwSum[4];
  3364. }MDxSum;
  3365.  
  3366. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3367. void STDCALL MDxInit( MDxSum * );
  3368. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3369. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3370. const char * STDCALL MDxGetVersion();
  3371. void STDCALL MDxFinalize( MDxSum * );
  3372.  
  3373.  
  3374.  
  3375. #include "mdx.h"
  3376. #include <stdlib.h>
  3377. #include <stdio.h>
  3378. #include <string.h>
  3379.  
  3380. // READLEN % 64 must = 0
  3381. #define READLEN    1048576L // 2^20, 1MB
  3382.  
  3383. void DigestFile( char * );
  3384. void DigestString();
  3385.  
  3386. void main(int argc, char *argv[])
  3387. {
  3388.     printf("%s\n\n", MDxGetVersion());
  3389.  
  3390.     if( argc > 1 )
  3391.         DigestFile( argv[1] );
  3392.     else    
  3393.         DigestString();
  3394.  
  3395. }
  3396.  
  3397. /*
  3398.     I use the 'chunk' method for processing files not because of
  3399.     limitations of my dll, but think what would happen if you
  3400.     tried to load an entire cd image into memory.
  3401. */
  3402. void DigestFile( char *szFName )
  3403. {
  3404.     FILE *file;
  3405.     void *lpData;
  3406.     long flen, mlen;
  3407.     MDxSum mdDataSum;
  3408.     MDxSum md4DataSum;
  3409.  
  3410.     // the 64 is for padding purposes
  3411.     lpData = malloc( READLEN + 64 );
  3412.     
  3413.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  3414.  
  3415.     file = fopen( szFName, "rb" );
  3416.     if( file == NULL )
  3417.     {
  3418.         printf("ERROR: File not found.\n");
  3419.         return;
  3420.     }
  3421.     
  3422.     MDxInit( &mdDataSum );
  3423.     MDxInit( &md4DataSum );
  3424.     
  3425.     fseek( file, 0, SEEK_END );
  3426.     //Get the file length
  3427.     flen = mlen = ftell( file );
  3428.     fseek( file, 0, SEEK_SET );
  3429.     
  3430.     // When it takes a while to process a large file,
  3431.     // remember that for each chunk it has to run 
  3432.     // through the main translation loop 16384 times!
  3433.         
  3434.     printf("Processing %ld byte file: .", flen );
  3435.     
  3436.     while( flen > READLEN )
  3437.     {
  3438.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  3439.         {
  3440.             printf("READ ERROR!\n");
  3441.             return;
  3442.         }
  3443.         MD5Translate( lpData, READLEN, &mdDataSum );
  3444.         MD4Translate( lpData, READLEN, &md4DataSum );
  3445.         flen -= READLEN;
  3446.         printf(".");
  3447.     }
  3448.  
  3449.     if (fread( lpData, 1, flen, file ) != flen)
  3450.     {
  3451.         printf("READ ERROR!\n");
  3452.         return;
  3453.     }
  3454.     // This is why I added the new argument to MDxPad
  3455.     // So we can pass the length of the data AND the
  3456.     // Total length of the message
  3457.     // Also it now returns the # of padding bytes added,
  3458.     // this is for files that are an exact multiple of the chunk
  3459.     // length. (Otherwise the padding isn't Translated)
  3460.     flen += MDxPad( lpData, flen, mlen );
  3461.     MD5Translate( lpData, flen, &mdDataSum );    
  3462.     MD4Translate( lpData, flen, &md4DataSum );
  3463.  
  3464.     // New step necessary because of the 'chunking' method
  3465.     MDxFinalize( &mdDataSum );
  3466.     MDxFinalize( &md4DataSum );
  3467.     
  3468.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3469.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3470.     fclose(file);
  3471.         
  3472. }
  3473.  
  3474. void DigestString()
  3475. {
  3476.     
  3477.     //For our demo purposes, no strings bigger than 1024 :)
  3478.     unsigned char lpData[1024] = "";
  3479.     long len = 0;
  3480.     MDxSum mdDataSum;
  3481.  
  3482.     printf("Enter the string to digest: ");
  3483.     scanf("%s", &lpData );
  3484.     len = strlen(lpData);
  3485.     
  3486.     // Have to do this before the Padding...well...it's best anyway;)
  3487.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3488.     
  3489.     // For the strings, we're gonna pad and digest the string
  3490.     // in one pass.
  3491.     MDxInit( &mdDataSum );
  3492.     MDxPad( lpData, len, len );
  3493.     
  3494.     MD5Translate( lpData, len, &mdDataSum );
  3495.         // New step necessary because of the 'chunking' method
  3496.         MDxFinalize( &mdDataSum );
  3497.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3498.     
  3499.     MDxInit( &mdDataSum );
  3500.     MD4Translate( lpData, len, &mdDataSum );    
  3501.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3502.  
  3503.     return;
  3504. }
  3505.  
  3506.  
  3507. -------------- Include
  3508.  
  3509. #ifndef __windows_h__
  3510.         typedef unsigned long DWORD;
  3511.         #define STDCALL _stdcall
  3512. #endif
  3513.  
  3514. typedef struct 
  3515. {
  3516.     DWORD dwSum[4];
  3517. }MDxSum;
  3518.  
  3519. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3520. void STDCALL MDxInit( MDxSum * );
  3521. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3522. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3523. const char * STDCALL MDxGetVersion();
  3524. void STDCALL MDxFinalize( MDxSum * );
  3525.  
  3526.  
  3527. #include "mdx.h"
  3528. #include <stdlib.h>
  3529. #include <stdio.h>
  3530. #include <string.h>
  3531.  
  3532. // READLEN % 64 must = 0
  3533. #define READLEN    1048576L // 2^20, 1MB
  3534.  
  3535. void DigestFile( char * );
  3536. void DigestString();
  3537.  
  3538. void main(int argc, char *argv[])
  3539. {
  3540.     printf("%s\n\n", MDxGetVersion());
  3541.  
  3542.     if( argc > 1 )
  3543.         DigestFile( argv[1] );
  3544.     else    
  3545.         DigestString();
  3546.  
  3547. }
  3548.  
  3549. /*
  3550.     I use the 'chunk' method for processing files not because of
  3551.     limitations of my dll, but think what would happen if you
  3552.     tried to load an entire cd image into memory.
  3553. */
  3554. void DigestFile( char *szFName )
  3555. {
  3556.     FILE *file;
  3557.     void *lpData;
  3558.     long flen, mlen;
  3559.     MDxSum mdDataSum;
  3560.     MDxSum md4DataSum;
  3561.  
  3562.     // the 64 is for padding purposes
  3563.     lpData = malloc( READLEN + 64 );
  3564.     
  3565.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  3566.  
  3567.     file = fopen( szFName, "rb" );
  3568.     if( file == NULL )
  3569.     {
  3570.         printf("ERROR: File not found.\n");
  3571.         return;
  3572.     }
  3573.     
  3574.     MDxInit( &mdDataSum );
  3575.     MDxInit( &md4DataSum );
  3576.     
  3577.     fseek( file, 0, SEEK_END );
  3578.     //Get the file length
  3579.     flen = mlen = ftell( file );
  3580.     fseek( file, 0, SEEK_SET );
  3581.     
  3582.     // When it takes a while to process a large file,
  3583.     // remember that for each chunk it has to run 
  3584.     // through the main translation loop 16384 times!
  3585.         
  3586.     printf("Processing %ld byte file: .", flen );
  3587.     
  3588.     while( flen > READLEN )
  3589.     {
  3590.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  3591.         {
  3592.             printf("READ ERROR!\n");
  3593.             return;
  3594.         }
  3595.         MD5Translate( lpData, READLEN, &mdDataSum );
  3596.         MD4Translate( lpData, READLEN, &md4DataSum );
  3597.         flen -= READLEN;
  3598.         printf(".");
  3599.     }
  3600.  
  3601.     if (fread( lpData, 1, flen, file ) != flen)
  3602.     {
  3603.         printf("READ ERROR!\n");
  3604.         return;
  3605.     }
  3606.     // This is why I added the new argument to MDxPad
  3607.     // So we can pass the length of the data AND the
  3608.     // Total length of the message
  3609.     // Also it now returns the # of padding bytes added,
  3610.     // this is for files that are an exact multiple of the chunk
  3611.     // length. (Otherwise the padding isn't Translated)
  3612.     flen += MDxPad( lpData, flen, mlen );
  3613.     MD5Translate( lpData, flen, &mdDataSum );    
  3614.     MD4Translate( lpData, flen, &md4DataSum );
  3615.  
  3616.     // New step necessary because of the 'chunking' method
  3617.     MDxFinalize( &mdDataSum );
  3618.     MDxFinalize( &md4DataSum );
  3619.     
  3620.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3621.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3622.     fclose(file);
  3623.         
  3624. }
  3625.  
  3626. void DigestString()
  3627. {
  3628.     
  3629.     //For our demo purposes, no strings bigger than 1024 :)
  3630.     unsigned char lpData[1024] = "";
  3631.     long len = 0;
  3632.     MDxSum mdDataSum;
  3633.  
  3634.     printf("Enter the string to digest: ");
  3635.     scanf("%s", &lpData );
  3636.     len = strlen(lpData);
  3637.     
  3638.     // Have to do this before the Padding...well...it's best anyway;)
  3639.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3640.     
  3641.     // For the strings, we're gonna pad and digest the string
  3642.     // in one pass.
  3643.     MDxInit( &mdDataSum );
  3644.     MDxPad( lpData, len, len );
  3645.     
  3646.     MD5Translate( lpData, len, &mdDataSum );
  3647.         // New step necessary because of the 'chunking' method
  3648.         MDxFinalize( &mdDataSum );
  3649.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3650.     
  3651.     MDxInit( &mdDataSum );
  3652.     MD4Translate( lpData, len, &mdDataSum );    
  3653.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3654.  
  3655.     return;
  3656. }
  3657.  
  3658.  
  3659. -------------- Include
  3660.  
  3661. #ifndef __windows_h__
  3662.         typedef unsigned long DWORD;
  3663.         #define STDCALL _stdcall
  3664. #endif
  3665.  
  3666. typedef struct 
  3667. {
  3668.     DWORD dwSum[4];
  3669. }MDxSum;
  3670.  
  3671. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3672. void STDCALL MDxInit( MDxSum * );
  3673. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3674. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3675. const char * STDCALL MDxGetVersion();
  3676. void STDCALL MDxFinalize( MDxSum * );
  3677.  
  3678.  
  3679. #include "mdx.h"
  3680. #include <stdlib.h>
  3681. #include <stdio.h>
  3682. #include <string.h>
  3683.  
  3684. // READLEN % 64 must = 0
  3685. #define READLEN    1048576L // 2^20, 1MB
  3686.  
  3687. void DigestFile( char * );
  3688. void DigestString();
  3689.  
  3690. void main(int argc, char *argv[])
  3691. {
  3692.     printf("%s\n\n", MDxGetVersion());
  3693.  
  3694.     if( argc > 1 )
  3695.         DigestFile( argv[1] );
  3696.     else    
  3697.         DigestString();
  3698.  
  3699. }
  3700.  
  3701. /*
  3702.     I use the 'chunk' method for processing files not because of
  3703.     limitations of my dll, but think what would happen if you
  3704.     tried to load an entire cd image into memory.
  3705. */
  3706. void DigestFile( char *szFName )
  3707. {
  3708.     FILE *file;
  3709.     void *lpData;
  3710.     long flen, mlen;
  3711.     MDxSum mdDataSum;
  3712.     MDxSum md4DataSum;
  3713.  
  3714.     // the 64 is for padding purposes
  3715.     lpData = malloc( READLEN + 64 );
  3716.     
  3717.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  3718.  
  3719.     file = fopen( szFName, "rb" );
  3720.     if( file == NULL )
  3721.     {
  3722.         printf("ERROR: File not found.\n");
  3723.         return;
  3724.     }
  3725.     
  3726.     MDxInit( &mdDataSum );
  3727.     MDxInit( &md4DataSum );
  3728.     
  3729.     fseek( file, 0, SEEK_END );
  3730.     //Get the file length
  3731.     flen = mlen = ftell( file );
  3732.     fseek( file, 0, SEEK_SET );
  3733.     
  3734.     // When it takes a while to process a large file,
  3735.     // remember that for each chunk it has to run 
  3736.     // through the main translation loop 16384 times!
  3737.         
  3738.     printf("Processing %ld byte file: .", flen );
  3739.     
  3740.     while( flen > READLEN )
  3741.     {
  3742.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  3743.         {
  3744.             printf("READ ERROR!\n");
  3745.             return;
  3746.         }
  3747.         MD5Translate( lpData, READLEN, &mdDataSum );
  3748.         MD4Translate( lpData, READLEN, &md4DataSum );
  3749.         flen -= READLEN;
  3750.         printf(".");
  3751.     }
  3752.  
  3753.     if (fread( lpData, 1, flen, file ) != flen)
  3754.     {
  3755.         printf("READ ERROR!\n");
  3756.         return;
  3757.     }
  3758.     // This is why I added the new argument to MDxPad
  3759.     // So we can pass the length of the data AND the
  3760.     // Total length of the message
  3761.     // Also it now returns the # of padding bytes added,
  3762.     // this is for files that are an exact multiple of the chunk
  3763.     // length. (Otherwise the padding isn't Translated)
  3764.     flen += MDxPad( lpData, flen, mlen );
  3765.     MD5Translate( lpData, flen, &mdDataSum );    
  3766.     MD4Translate( lpData, flen, &md4DataSum );
  3767.  
  3768.     // New step necessary because of the 'chunking' method
  3769.     MDxFinalize( &mdDataSum );
  3770.     MDxFinalize( &md4DataSum );
  3771.     
  3772.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3773.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3774.     fclose(file);
  3775.         
  3776. }
  3777.  
  3778. void DigestString()
  3779. {
  3780.     
  3781.     //For our demo purposes, no strings bigger than 1024 :)
  3782.     unsigned char lpData[1024] = "";
  3783.     long len = 0;
  3784.     MDxSum mdDataSum;
  3785.  
  3786.     printf("Enter the string to digest: ");
  3787.     scanf("%s", &lpData );
  3788.     len = strlen(lpData);
  3789.     
  3790.     // Have to do this before the Padding...well...it's best anyway;)
  3791.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3792.     
  3793.     // For the strings, we're gonna pad and digest the string
  3794.     // in one pass.
  3795.     MDxInit( &mdDataSum );
  3796.     MDxPad( lpData, len, len );
  3797.     
  3798.     MD5Translate( lpData, len, &mdDataSum );
  3799.         // New step necessary because of the 'chunking' method
  3800.         MDxFinalize( &mdDataSum );
  3801.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3802.     
  3803.     MDxInit( &mdDataSum );
  3804.     MD4Translate( lpData, len, &mdDataSum );    
  3805.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3806.  
  3807.     return;
  3808. }
  3809.  
  3810.  
  3811. -------------- Include
  3812.  
  3813. #ifndef __windows_h__
  3814.         typedef unsigned long DWORD;
  3815.         #define STDCALL _stdcall
  3816. #endif
  3817.  
  3818. typedef struct 
  3819. {
  3820.     DWORD dwSum[4];
  3821. }MDxSum;
  3822.  
  3823. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3824. void STDCALL MDxInit( MDxSum * );
  3825. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3826. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3827. const char * STDCALL MDxGetVersion();
  3828. void STDCALL MDxFinalize( MDxSum * );
  3829.  
  3830.  
  3831.  
  3832. #include "mdx.h"
  3833. #include <stdlib.h>
  3834. #include <stdio.h>
  3835. #include <string.h>
  3836.  
  3837. // READLEN % 64 must = 0
  3838. #define READLEN    1048576L // 2^20, 1MB
  3839.  
  3840. void DigestFile( char * );
  3841. void DigestString();
  3842.  
  3843. void main(int argc, char *argv[])
  3844. {
  3845.     printf("%s\n\n", MDxGetVersion());
  3846.  
  3847.     if( argc > 1 )
  3848.         DigestFile( argv[1] );
  3849.     else    
  3850.         DigestString();
  3851.  
  3852. }
  3853.  
  3854. /*
  3855.     I use the 'chunk' method for processing files not because of
  3856.     limitations of my dll, but think what would happen if you
  3857.     tried to load an entire cd image into memory.
  3858. */
  3859. void DigestFile( char *szFName )
  3860. {
  3861.     FILE *file;
  3862.     void *lpData;
  3863.     long flen, mlen;
  3864.     MDxSum mdDataSum;
  3865.     MDxSum md4DataSum;
  3866.  
  3867.     // the 64 is for padding purposes
  3868.     lpData = malloc( READLEN + 64 );
  3869.     
  3870.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  3871.  
  3872.     file = fopen( szFName, "rb" );
  3873.     if( file == NULL )
  3874.     {
  3875.         printf("ERROR: File not found.\n");
  3876.         return;
  3877.     }
  3878.     
  3879.     MDxInit( &mdDataSum );
  3880.     MDxInit( &md4DataSum );
  3881.     
  3882.     fseek( file, 0, SEEK_END );
  3883.     //Get the file length
  3884.     flen = mlen = ftell( file );
  3885.     fseek( file, 0, SEEK_SET );
  3886.     
  3887.     // When it takes a while to process a large file,
  3888.     // remember that for each chunk it has to run 
  3889.     // through the main translation loop 16384 times!
  3890.         
  3891.     printf("Processing %ld byte file: .", flen );
  3892.     
  3893.     while( flen > READLEN )
  3894.     {
  3895.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  3896.         {
  3897.             printf("READ ERROR!\n");
  3898.             return;
  3899.         }
  3900.         MD5Translate( lpData, READLEN, &mdDataSum );
  3901.         MD4Translate( lpData, READLEN, &md4DataSum );
  3902.         flen -= READLEN;
  3903.         printf(".");
  3904.     }
  3905.  
  3906.     if (fread( lpData, 1, flen, file ) != flen)
  3907.     {
  3908.         printf("READ ERROR!\n");
  3909.         return;
  3910.     }
  3911.     // This is why I added the new argument to MDxPad
  3912.     // So we can pass the length of the data AND the
  3913.     // Total length of the message
  3914.     // Also it now returns the # of padding bytes added,
  3915.     // this is for files that are an exact multiple of the chunk
  3916.     // length. (Otherwise the padding isn't Translated)
  3917.     flen += MDxPad( lpData, flen, mlen );
  3918.     MD5Translate( lpData, flen, &mdDataSum );    
  3919.     MD4Translate( lpData, flen, &md4DataSum );
  3920.  
  3921.     // New step necessary because of the 'chunking' method
  3922.     MDxFinalize( &mdDataSum );
  3923.     MDxFinalize( &md4DataSum );
  3924.     
  3925.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  3926.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3927.     fclose(file);
  3928.         
  3929. }
  3930.  
  3931. void DigestString()
  3932. {
  3933.     
  3934.     //For our demo purposes, no strings bigger than 1024 :)
  3935.     unsigned char lpData[1024] = "";
  3936.     long len = 0;
  3937.     MDxSum mdDataSum;
  3938.  
  3939.     printf("Enter the string to digest: ");
  3940.     scanf("%s", &lpData );
  3941.     len = strlen(lpData);
  3942.     
  3943.     // Have to do this before the Padding...well...it's best anyway;)
  3944.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  3945.     
  3946.     // For the strings, we're gonna pad and digest the string
  3947.     // in one pass.
  3948.     MDxInit( &mdDataSum );
  3949.     MDxPad( lpData, len, len );
  3950.     
  3951.     MD5Translate( lpData, len, &mdDataSum );
  3952.         // New step necessary because of the 'chunking' method
  3953.         MDxFinalize( &mdDataSum );
  3954.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3955.     
  3956.     MDxInit( &mdDataSum );
  3957.     MD4Translate( lpData, len, &mdDataSum );    
  3958.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  3959.  
  3960.     return;
  3961. }
  3962.  
  3963.  
  3964. -------------- Include
  3965.  
  3966. #ifndef __windows_h__
  3967.         typedef unsigned long DWORD;
  3968.         #define STDCALL _stdcall
  3969. #endif
  3970.  
  3971. typedef struct 
  3972. {
  3973.     DWORD dwSum[4];
  3974. }MDxSum;
  3975.  
  3976. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  3977. void STDCALL MDxInit( MDxSum * );
  3978. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  3979. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  3980. const char * STDCALL MDxGetVersion();
  3981. void STDCALL MDxFinalize( MDxSum * );
  3982.  
  3983.  
  3984.  
  3985. #include "mdx.h"
  3986. #include <stdlib.h>
  3987. #include <stdio.h>
  3988. #include <string.h>
  3989.  
  3990. // READLEN % 64 must = 0
  3991. #define READLEN    1048576L // 2^20, 1MB
  3992.  
  3993. void DigestFile( char * );
  3994. void DigestString();
  3995.  
  3996. void main(int argc, char *argv[])
  3997. {
  3998.     printf("%s\n\n", MDxGetVersion());
  3999.  
  4000.     if( argc > 1 )
  4001.         DigestFile( argv[1] );
  4002.     else    
  4003.         DigestString();
  4004.  
  4005. }
  4006.  
  4007. /*
  4008.     I use the 'chunk' method for processing files not because of
  4009.     limitations of my dll, but think what would happen if you
  4010.     tried to load an entire cd image into memory.
  4011. */
  4012. void DigestFile( char *szFName )
  4013. {
  4014.     FILE *file;
  4015.     void *lpData;
  4016.     long flen, mlen;
  4017.     MDxSum mdDataSum;
  4018.     MDxSum md4DataSum;
  4019.  
  4020.     // the 64 is for padding purposes
  4021.     lpData = malloc( READLEN + 64 );
  4022.     
  4023.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4024.  
  4025.     file = fopen( szFName, "rb" );
  4026.     if( file == NULL )
  4027.     {
  4028.         printf("ERROR: File not found.\n");
  4029.         return;
  4030.     }
  4031.     
  4032.     MDxInit( &mdDataSum );
  4033.     MDxInit( &md4DataSum );
  4034.     
  4035.     fseek( file, 0, SEEK_END );
  4036.     //Get the file length
  4037.     flen = mlen = ftell( file );
  4038.     fseek( file, 0, SEEK_SET );
  4039.     
  4040.     // When it takes a while to process a large file,
  4041.     // remember that for each chunk it has to run 
  4042.     // through the main translation loop 16384 times!
  4043.         
  4044.     printf("Processing %ld byte file: .", flen );
  4045.     
  4046.     while( flen > READLEN )
  4047.     {
  4048.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4049.         {
  4050.             printf("READ ERROR!\n");
  4051.             return;
  4052.         }
  4053.         MD5Translate( lpData, READLEN, &mdDataSum );
  4054.         MD4Translate( lpData, READLEN, &md4DataSum );
  4055.         flen -= READLEN;
  4056.         printf(".");
  4057.     }
  4058.  
  4059.     if (fread( lpData, 1, flen, file ) != flen)
  4060.     {
  4061.         printf("READ ERROR!\n");
  4062.         return;
  4063.     }
  4064.     // This is why I added the new argument to MDxPad
  4065.     // So we can pass the length of the data AND the
  4066.     // Total length of the message
  4067.     // Also it now returns the # of padding bytes added,
  4068.     // this is for files that are an exact multiple of the chunk
  4069.     // length. (Otherwise the padding isn't Translated)
  4070.     flen += MDxPad( lpData, flen, mlen );
  4071.     MD5Translate( lpData, flen, &mdDataSum );    
  4072.     MD4Translate( lpData, flen, &md4DataSum );
  4073.  
  4074.     // New step necessary because of the 'chunking' method
  4075.     MDxFinalize( &mdDataSum );
  4076.     MDxFinalize( &md4DataSum );
  4077.     
  4078.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4079.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4080.     fclose(file);
  4081.         
  4082. }
  4083.  
  4084. void DigestString()
  4085. {
  4086.     
  4087.     //For our demo purposes, no strings bigger than 1024 :)
  4088.     unsigned char lpData[1024] = "";
  4089.     long len = 0;
  4090.     MDxSum mdDataSum;
  4091.  
  4092.     printf("Enter the string to digest: ");
  4093.     scanf("%s", &lpData );
  4094.     len = strlen(lpData);
  4095.     
  4096.     // Have to do this before the Padding...well...it's best anyway;)
  4097.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  4098.     
  4099.     // For the strings, we're gonna pad and digest the string
  4100.     // in one pass.
  4101.     MDxInit( &mdDataSum );
  4102.     MDxPad( lpData, len, len );
  4103.     
  4104.     MD5Translate( lpData, len, &mdDataSum );
  4105.         // New step necessary because of the 'chunking' method
  4106.         MDxFinalize( &mdDataSum );
  4107.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4108.     
  4109.     MDxInit( &mdDataSum );
  4110.     MD4Translate( lpData, len, &mdDataSum );    
  4111.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4112.  
  4113.     return;
  4114. }
  4115.  
  4116.  
  4117. -------------- Include
  4118.  
  4119. #ifndef __windows_h__
  4120.         typedef unsigned long DWORD;
  4121.         #define STDCALL _stdcall
  4122. #endif
  4123.  
  4124. typedef struct 
  4125. {
  4126.     DWORD dwSum[4];
  4127. }MDxSum;
  4128.  
  4129. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  4130. void STDCALL MDxInit( MDxSum * );
  4131. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  4132. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  4133. const char * STDCALL MDxGetVersion();
  4134. void STDCALL MDxFinalize( MDxSum * );
  4135.  
  4136.  
  4137.  
  4138. #include "mdx.h"
  4139. #include <stdlib.h>
  4140. #include <stdio.h>
  4141. #include <string.h>
  4142.  
  4143. // READLEN % 64 must = 0
  4144. #define READLEN    1048576L // 2^20, 1MB
  4145.  
  4146. void DigestFile( char * );
  4147. void DigestString();
  4148.  
  4149. void main(int argc, char *argv[])
  4150. {
  4151.     printf("%s\n\n", MDxGetVersion());
  4152.  
  4153.     if( argc > 1 )
  4154.         DigestFile( argv[1] );
  4155.     else    
  4156.         DigestString();
  4157.  
  4158. }
  4159.  
  4160. /*
  4161.     I use the 'chunk' method for processing files not because of
  4162.     limitations of my dll, but think what would happen if you
  4163.     tried to load an entire cd image into memory.
  4164. */
  4165. void DigestFile( char *szFName )
  4166. {
  4167.     FILE *file;
  4168.     void *lpData;
  4169.     long flen, mlen;
  4170.     MDxSum mdDataSum;
  4171.     MDxSum md4DataSum;
  4172.  
  4173.     // the 64 is for padding purposes
  4174.     lpData = malloc( READLEN + 64 );
  4175.     
  4176.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4177.  
  4178.     file = fopen( szFName, "rb" );
  4179.     if( file == NULL )
  4180.     {
  4181.         printf("ERROR: File not found.\n");
  4182.         return;
  4183.     }
  4184.     
  4185.     MDxInit( &mdDataSum );
  4186.     MDxInit( &md4DataSum );
  4187.     
  4188.     fseek( file, 0, SEEK_END );
  4189.     //Get the file length
  4190.     flen = mlen = ftell( file );
  4191.     fseek( file, 0, SEEK_SET );
  4192.     
  4193.     // When it takes a while to process a large file,
  4194.     // remember that for each chunk it has to run 
  4195.     // through the main translation loop 16384 times!
  4196.         
  4197.     printf("Processing %ld byte file: .", flen );
  4198.     
  4199.     while( flen > READLEN )
  4200.     {
  4201.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4202.         {
  4203.             printf("READ ERROR!\n");
  4204.             return;
  4205.         }
  4206.         MD5Translate( lpData, READLEN, &mdDataSum );
  4207.         MD4Translate( lpData, READLEN, &md4DataSum );
  4208.         flen -= READLEN;
  4209.         printf(".");
  4210.     }
  4211.  
  4212.     if (fread( lpData, 1, flen, file ) != flen)
  4213.     {
  4214.         printf("READ ERROR!\n");
  4215.         return;
  4216.     }
  4217.     // This is why I added the new argument to MDxPad
  4218.     // So we can pass the length of the data AND the
  4219.     // Total length of the message
  4220.     // Also it now returns the # of padding bytes added,
  4221.     // this is for files that are an exact multiple of the chunk
  4222.     // length. (Otherwise the padding isn't Translated)
  4223.     flen += MDxPad( lpData, flen, mlen );
  4224.     MD5Translate( lpData, flen, &mdDataSum );    
  4225.     MD4Translate( lpData, flen, &md4DataSum );
  4226.  
  4227.     // New step necessary because of the 'chunking' method
  4228.     MDxFinalize( &mdDataSum );
  4229.     MDxFinalize( &md4DataSum );
  4230.     
  4231.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4232.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4233.     fclose(file);
  4234.         
  4235. }
  4236.  
  4237. void DigestString()
  4238. {
  4239.     
  4240.     //For our demo purposes, no strings bigger than 1024 :)
  4241.     unsigned char lpData[1024] = "";
  4242.     long len = 0;
  4243.     MDxSum mdDataSum;
  4244.  
  4245.     printf("Enter the string to digest: ");
  4246.     scanf("%s", &lpData );
  4247.     len = strlen(lpData);
  4248.     
  4249.     // Have to do this before the Padding...well...it's best anyway;)
  4250.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  4251.     
  4252.     // For the strings, we're gonna pad and digest the string
  4253.     // in one pass.
  4254.     MDxInit( &mdDataSum );
  4255.     MDxPad( lpData, len, len );
  4256.     
  4257.     MD5Translate( lpData, len, &mdDataSum );
  4258.         // New step necessary because of the 'chunking' method
  4259.         MDxFinalize( &mdDataSum );
  4260.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4261.     
  4262.     MDxInit( &mdDataSum );
  4263.     MD4Translate( lpData, len, &mdDataSum );    
  4264.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4265.  
  4266.     return;
  4267. }
  4268.  
  4269.  
  4270. -------------- Include
  4271.  
  4272. #ifndef __windows_h__
  4273.         typedef unsigned long DWORD;
  4274.         #define STDCALL _stdcall
  4275. #endif
  4276.  
  4277. typedef struct 
  4278. {
  4279.     DWORD dwSum[4];
  4280. }MDxSum;
  4281.  
  4282. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  4283. void STDCALL MDxInit( MDxSum * );
  4284. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  4285. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  4286. const char * STDCALL MDxGetVersion();
  4287. void STDCALL MDxFinalize( MDxSum * );
  4288.  
  4289.  
  4290.  
  4291. #include "mdx.h"
  4292. #include <stdlib.h>
  4293. #include <stdio.h>
  4294. #include <string.h>
  4295.  
  4296. // READLEN % 64 must = 0
  4297. #define READLEN    1048576L // 2^20, 1MB
  4298.  
  4299. void DigestFile( char * );
  4300. void DigestString();
  4301.  
  4302. void main(int argc, char *argv[])
  4303. {
  4304.     printf("%s\n\n", MDxGetVersion());
  4305.  
  4306.     if( argc > 1 )
  4307.         DigestFile( argv[1] );
  4308.     else    
  4309.         DigestString();
  4310.  
  4311. }
  4312.  
  4313. /*
  4314.     I use the 'chunk' method for processing files not because of
  4315.     limitations of my dll, but think what would happen if you
  4316.     tried to load an entire cd image into memory.
  4317. */
  4318. void DigestFile( char *szFName )
  4319. {
  4320.     FILE *file;
  4321.     void *lpData;
  4322.     long flen, mlen;
  4323.     MDxSum mdDataSum;
  4324.     MDxSum md4DataSum;
  4325.  
  4326.     // the 64 is for padding purposes
  4327.     lpData = malloc( READLEN + 64 );
  4328.     
  4329.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4330.  
  4331.     file = fopen( szFName, "rb" );
  4332.     if( file == NULL )
  4333.     {
  4334.         printf("ERROR: File not found.\n");
  4335.         return;
  4336.     }
  4337.     
  4338.     MDxInit( &mdDataSum );
  4339.     MDxInit( &md4DataSum );
  4340.     
  4341.     fseek( file, 0, SEEK_END );
  4342.     //Get the file length
  4343.     flen = mlen = ftell( file );
  4344.     fseek( file, 0, SEEK_SET );
  4345.     
  4346.     // When it takes a while to process a large file,
  4347.     // remember that for each chunk it has to run 
  4348.     // through the main translation loop 16384 times!
  4349.         
  4350.     printf("Processing %ld byte file: .", flen );
  4351.     
  4352.     while( flen > READLEN )
  4353.     {
  4354.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4355.         {
  4356.             printf("READ ERROR!\n");
  4357.             return;
  4358.         }
  4359.         MD5Translate( lpData, READLEN, &mdDataSum );
  4360.         MD4Translate( lpData, READLEN, &md4DataSum );
  4361.         flen -= READLEN;
  4362.         printf(".");
  4363.     }
  4364.  
  4365.     if (fread( lpData, 1, flen, file ) != flen)
  4366.     {
  4367.         printf("READ ERROR!\n");
  4368.         return;
  4369.     }
  4370.     // This is why I added the new argument to MDxPad
  4371.     // So we can pass the length of the data AND the
  4372.     // Total length of the message
  4373.     // Also it now returns the # of padding bytes added,
  4374.     // this is for files that are an exact multiple of the chunk
  4375.     // length. (Otherwise the padding isn't Translated)
  4376.     flen += MDxPad( lpData, flen, mlen );
  4377.     MD5Translate( lpData, flen, &mdDataSum );    
  4378.     MD4Translate( lpData, flen, &md4DataSum );
  4379.  
  4380.     // New step necessary because of the 'chunking' method
  4381.     MDxFinalize( &mdDataSum );
  4382.     MDxFinalize( &md4DataSum );
  4383.     
  4384.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4385.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4386.     fclose(file);
  4387.         
  4388. }
  4389.  
  4390. void DigestString()
  4391. {
  4392.     
  4393.     //For our demo purposes, no strings bigger than 1024 :)
  4394.     unsigned char lpData[1024] = "";
  4395.     long len = 0;
  4396.     MDxSum mdDataSum;
  4397.  
  4398.     printf("Enter the string to digest: ");
  4399.     scanf("%s", &lpData );
  4400.     len = strlen(lpData);
  4401.     
  4402.     // Have to do this before the Padding...well...it's best anyway;)
  4403.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  4404.     
  4405.     // For the strings, we're gonna pad and digest the string
  4406.     // in one pass.
  4407.     MDxInit( &mdDataSum );
  4408.     MDxPad( lpData, len, len );
  4409.     
  4410.     MD5Translate( lpData, len, &mdDataSum );
  4411.         // New step necessary because of the 'chunking' method
  4412.         MDxFinalize( &mdDataSum );
  4413.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4414.     
  4415.     MDxInit( &mdDataSum );
  4416.     MD4Translate( lpData, len, &mdDataSum );    
  4417.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4418.  
  4419.     return;
  4420. }
  4421.  
  4422.  
  4423. -------------- Include
  4424.  
  4425. #ifndef __windows_h__
  4426.         typedef unsigned long DWORD;
  4427.         #define STDCALL _stdcall
  4428. #endif
  4429.  
  4430. typedef struct 
  4431. {
  4432.     DWORD dwSum[4];
  4433. }MDxSum;
  4434.  
  4435. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  4436. void STDCALL MDxInit( MDxSum * );
  4437. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  4438. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  4439. const char * STDCALL MDxGetVersion();
  4440. void STDCALL MDxFinalize( MDxSum * );
  4441.  
  4442.  
  4443.  
  4444. #include "mdx.h"
  4445. #include <stdlib.h>
  4446. #include <stdio.h>
  4447. #include <string.h>
  4448.  
  4449. // READLEN % 64 must = 0
  4450. #define READLEN    1048576L // 2^20, 1MB
  4451.  
  4452. void DigestFile( char * );
  4453. void DigestString();
  4454.  
  4455. void main(int argc, char *argv[])
  4456. {
  4457.     printf("%s\n\n", MDxGetVersion());
  4458.  
  4459.     if( argc > 1 )
  4460.         DigestFile( argv[1] );
  4461.     else    
  4462.         DigestString();
  4463.  
  4464. }
  4465.  
  4466. /*
  4467.     I use the 'chunk' method for processing files not because of
  4468.     limitations of my dll, but think what would happen if you
  4469.     tried to load an entire cd image into memory.
  4470. */
  4471. void DigestFile( char *szFName )
  4472. {
  4473.     FILE *file;
  4474.     void *lpData;
  4475.     long flen, mlen;
  4476.     MDxSum mdDataSum;
  4477.     MDxSum md4DataSum;
  4478.  
  4479.     // the 64 is for padding purposes
  4480.     lpData = malloc( READLEN + 64 );
  4481.     
  4482.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4483.  
  4484.     file = fopen( szFName, "rb" );
  4485.     if( file == NULL )
  4486.     {
  4487.         printf("ERROR: File not found.\n");
  4488.         return;
  4489.     }
  4490.     
  4491.     MDxInit( &mdDataSum );
  4492.     MDxInit( &md4DataSum );
  4493.     
  4494.     fseek( file, 0, SEEK_END );
  4495.     //Get the file length
  4496.     flen = mlen = ftell( file );
  4497.     fseek( file, 0, SEEK_SET );
  4498.     
  4499.     // When it takes a while to process a large file,
  4500.     // remember that for each chunk it has to run 
  4501.     // through the main translation loop 16384 times!
  4502.         
  4503.     printf("Processing %ld byte file: .", flen );
  4504.     
  4505.     while( flen > READLEN )
  4506.     {
  4507.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4508.         {
  4509.             printf("READ ERROR!\n");
  4510.             return;
  4511.         }
  4512.         MD5Translate( lpData, READLEN, &mdDataSum );
  4513.         MD4Translate( lpData, READLEN, &md4DataSum );
  4514.         flen -= READLEN;
  4515.         printf(".");
  4516.     }
  4517.  
  4518.     if (fread( lpData, 1, flen, file ) != flen)
  4519.     {
  4520.         printf("READ ERROR!\n");
  4521.         return;
  4522.     }
  4523.     // This is why I added the new argument to MDxPad
  4524.     // So we can pass the length of the data AND the
  4525.     // Total length of the message
  4526.     // Also it now returns the # of padding bytes added,
  4527.     // this is for files that are an exact multiple of the chunk
  4528.     // length. (Otherwise the padding isn't Translated)
  4529.     flen += MDxPad( lpData, flen, mlen );
  4530.     MD5Translate( lpData, flen, &mdDataSum );    
  4531.     MD4Translate( lpData, flen, &md4DataSum );
  4532.  
  4533.     // New step necessary because of the 'chunking' method
  4534.     MDxFinalize( &mdDataSum );
  4535.     MDxFinalize( &md4DataSum );
  4536.     
  4537.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4538.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4539.     fclose(file);
  4540.         
  4541. }
  4542.  
  4543. void DigestString()
  4544. {
  4545.     
  4546.     //For our demo purposes, no strings bigger than 1024 :)
  4547.     unsigned char lpData[1024] = "";
  4548.     long len = 0;
  4549.     MDxSum mdDataSum;
  4550.  
  4551.     printf("Enter the string to digest: ");
  4552.     scanf("%s", &lpData );
  4553.     len = strlen(lpData);
  4554.     
  4555.     // Have to do this before the Padding...well...it's best anyway;)
  4556.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  4557.     
  4558.     // For the strings, we're gonna pad and digest the string
  4559.     // in one pass.
  4560.     MDxInit( &mdDataSum );
  4561.     MDxPad( lpData, len, len );
  4562.     
  4563.     MD5Translate( lpData, len, &mdDataSum );
  4564.         // New step necessary because of the 'chunking' method
  4565.         MDxFinalize( &mdDataSum );
  4566.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4567.     
  4568.     MDxInit( &mdDataSum );
  4569.     MD4Translate( lpData, len, &mdDataSum );    
  4570.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4571.  
  4572.     return;
  4573. }
  4574.  
  4575.  
  4576. -------------- Include
  4577.  
  4578. #ifndef __windows_h__
  4579.         typedef unsigned long DWORD;
  4580.         #define STDCALL _stdcall
  4581. #endif
  4582.  
  4583. typedef struct 
  4584. {
  4585.     DWORD dwSum[4];
  4586. }MDxSum;
  4587.  
  4588. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  4589. void STDCALL MDxInit( MDxSum * );
  4590. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  4591. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  4592. const char * STDCALL MDxGetVersion();
  4593. void STDCALL MDxFinalize( MDxSum * );
  4594.  
  4595.  
  4596.  
  4597. #include "mdx.h"
  4598. #include <stdlib.h>
  4599. #include <stdio.h>
  4600. #include <string.h>
  4601.  
  4602. // READLEN % 64 must = 0
  4603. #define READLEN    1048576L // 2^20, 1MB
  4604.  
  4605. void DigestFile( char * );
  4606. void DigestString();
  4607.  
  4608. void main(int argc, char *argv[])
  4609. {
  4610.     printf("%s\n\n", MDxGetVersion());
  4611.  
  4612.     if( argc > 1 )
  4613.         DigestFile( argv[1] );
  4614.     else    
  4615.         DigestString();
  4616.  
  4617. }
  4618.  
  4619. /*
  4620.     I use the 'chunk' method for processing files not because of
  4621.     limitations of my dll, but think what would happen if you
  4622.     tried to load an entire cd image into memory.
  4623. */
  4624. void DigestFile( char *szFName )
  4625. {
  4626.     FILE *file;
  4627.     void *lpData;
  4628.     long flen, mlen;
  4629.     MDxSum mdDataSum;
  4630.     MDxSum md4DataSum;
  4631.  
  4632.     // the 64 is for padding purposes
  4633.     lpData = malloc( READLEN + 64 );
  4634.     
  4635.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4636.  
  4637.     file = fopen( szFName, "rb" );
  4638.     if( file == NULL )
  4639.     {
  4640.         printf("ERROR: File not found.\n");
  4641.         return;
  4642.     }
  4643.     
  4644.     MDxInit( &mdDataSum );
  4645.     MDxInit( &md4DataSum );
  4646.     
  4647.     fseek( file, 0, SEEK_END );
  4648.     //Get the file length
  4649.     flen = mlen = ftell( file );
  4650.     fseek( file, 0, SEEK_SET );
  4651.     
  4652.     // When it takes a while to process a large file,
  4653.     // remember that for each chunk it has to run 
  4654.     // through the main translation loop 16384 times!
  4655.         
  4656.     printf("Processing %ld byte file: .", flen );
  4657.     
  4658.     while( flen > READLEN )
  4659.     {
  4660.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4661.         {
  4662.             printf("READ ERROR!\n");
  4663.             return;
  4664.         }
  4665.         MD5Translate( lpData, READLEN, &mdDataSum );
  4666.         MD4Translate( lpData, READLEN, &md4DataSum );
  4667.         flen -= READLEN;
  4668.         printf(".");
  4669.     }
  4670.  
  4671.     if (fread( lpData, 1, flen, file ) != flen)
  4672.     {
  4673.         printf("READ ERROR!\n");
  4674.         return;
  4675.     }
  4676.     // This is why I added the new argument to MDxPad
  4677.     // So we can pass the length of the data AND the
  4678.     // Total length of the message
  4679.     // Also it now returns the # of padding bytes added,
  4680.     // this is for files that are an exact multiple of the chunk
  4681.     // length. (Otherwise the padding isn't Translated)
  4682.     flen += MDxPad( lpData, flen, mlen );
  4683.     MD5Translate( lpData, flen, &mdDataSum );    
  4684.     MD4Translate( lpData, flen, &md4DataSum );
  4685.  
  4686.     // New step necessary because of the 'chunking' method
  4687.     MDxFinalize( &mdDataSum );
  4688.     MDxFinalize( &md4DataSum );
  4689.     
  4690.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4691.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4692.     fclose(file);
  4693.         
  4694. }
  4695.  
  4696. void DigestString()
  4697. {
  4698.     
  4699.     //For our demo purposes, no strings bigger than 1024 :)
  4700.     unsigned char lpData[1024] = "";
  4701.     long len = 0;
  4702.     MDxSum mdDataSum;
  4703.  
  4704.     printf("Enter the string to digest: ");
  4705.     scanf("%s", &lpData );
  4706.     len = strlen(lpData);
  4707.     
  4708.     // Have to do this before the Padding...well...it's best anyway;)
  4709.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  4710.     
  4711.     // For the strings, we're gonna pad and digest the string
  4712.     // in one pass.
  4713.     MDxInit( &mdDataSum );
  4714.     MDxPad( lpData, len, len );
  4715.     
  4716.     MD5Translate( lpData, len, &mdDataSum );
  4717.         // New step necessary because of the 'chunking' method
  4718.         MDxFinalize( &mdDataSum );
  4719.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4720.     
  4721.     MDxInit( &mdDataSum );
  4722.     MD4Translate( lpData, len, &mdDataSum );    
  4723.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4724.  
  4725.     return;
  4726. }
  4727.  
  4728.  
  4729. -------------- Include
  4730.  
  4731. #ifndef __windows_h__
  4732.         typedef unsigned long DWORD;
  4733.         #define STDCALL _stdcall
  4734. #endif
  4735.  
  4736. typedef struct 
  4737. {
  4738.     DWORD dwSum[4];
  4739. }MDxSum;
  4740.  
  4741. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  4742. void STDCALL MDxInit( MDxSum * );
  4743. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  4744. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  4745. const char * STDCALL MDxGetVersion();
  4746. void STDCALL MDxFinalize( MDxSum * );
  4747.  
  4748.  
  4749.  
  4750. #include "mdx.h"
  4751. #include <stdlib.h>
  4752. #include <stdio.h>
  4753. #include <string.h>
  4754.  
  4755. // READLEN % 64 must = 0
  4756. #define READLEN    1048576L // 2^20, 1MB
  4757.  
  4758. void DigestFile( char * );
  4759. void DigestString();
  4760.  
  4761. void main(int argc, char *argv[])
  4762. {
  4763.     printf("%s\n\n", MDxGetVersion());
  4764.  
  4765.     if( argc > 1 )
  4766.         DigestFile( argv[1] );
  4767.     else    
  4768.         DigestString();
  4769.  
  4770. }
  4771.  
  4772. /*
  4773.     I use the 'chunk' method for processing files not because of
  4774.     limitations of my dll, but think what would happen if you
  4775.     tried to load an entire cd image into memory.
  4776. */
  4777. void DigestFile( char *szFName )
  4778. {
  4779.     FILE *file;
  4780.     void *lpData;
  4781.     long flen, mlen;
  4782.     MDxSum mdDataSum;
  4783.     MDxSum md4DataSum;
  4784.  
  4785.     // the 64 is for padding purposes
  4786.     lpData = malloc( READLEN + 64 );
  4787.     
  4788.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4789.  
  4790.     file = fopen( szFName, "rb" );
  4791.     if( file == NULL )
  4792.     {
  4793.         printf("ERROR: File not found.\n");
  4794.         return;
  4795.     }
  4796.     
  4797.     MDxInit( &mdDataSum );
  4798.     MDxInit( &md4DataSum );
  4799.     
  4800.     fseek( file, 0, SEEK_END );
  4801.     //Get the file length
  4802.     flen = mlen = ftell( file );
  4803.     fseek( file, 0, SEEK_SET );
  4804.     
  4805.     // When it takes a while to process a large file,
  4806.     // remember that for each chunk it has to run 
  4807.     // through the main translation loop 16384 times!
  4808.         
  4809.     printf("Processing %ld byte file: .", flen );
  4810.     
  4811.     while( flen > READLEN )
  4812.     {
  4813.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4814.         {
  4815.             printf("READ ERROR!\n");
  4816.             return;
  4817.         }
  4818.         MD5Translate( lpData, READLEN, &mdDataSum );
  4819.         MD4Translate( lpData, READLEN, &md4DataSum );
  4820.         flen -= READLEN;
  4821.         printf(".");
  4822.     }
  4823.  
  4824.     if (fread( lpData, 1, flen, file ) != flen)
  4825.     {
  4826.         printf("READ ERROR!\n");
  4827.         return;
  4828.     }
  4829.     // This is why I added the new argument to MDxPad
  4830.     // So we can pass the length of the data AND the
  4831.     // Total length of the message
  4832.     // Also it now returns the # of padding bytes added,
  4833.     // this is for files that are an exact multiple of the chunk
  4834.     // length. (Otherwise the padding isn't Translated)
  4835.     flen += MDxPad( lpData, flen, mlen );
  4836.     MD5Translate( lpData, flen, &mdDataSum );    
  4837.     MD4Translate( lpData, flen, &md4DataSum );
  4838.  
  4839.     // New step necessary because of the 'chunking' method
  4840.     MDxFinalize( &mdDataSum );
  4841.     MDxFinalize( &md4DataSum );
  4842.     
  4843.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4844.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4845.     fclose(file);
  4846.         
  4847. }
  4848.  
  4849. void DigestString()
  4850. {
  4851.     
  4852.     //For our demo purposes, no strings bigger than 1024 :)
  4853.     unsigned char lpData[1024] = "";
  4854.     long len = 0;
  4855.     MDxSum mdDataSum;
  4856.  
  4857.     printf("Enter the string to digest: ");
  4858.     scanf("%s", &lpData );
  4859.     len = strlen(lpData);
  4860.     
  4861.     // Have to do this before the Padding...well...it's best anyway;)
  4862.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  4863.     
  4864.     // For the strings, we're gonna pad and digest the string
  4865.     // in one pass.
  4866.     MDxInit( &mdDataSum );
  4867.     MDxPad( lpData, len, len );
  4868.     
  4869.     MD5Translate( lpData, len, &mdDataSum );
  4870.         // New step necessary because of the 'chunking' method
  4871.         MDxFinalize( &mdDataSum );
  4872.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4873.     
  4874.     MDxInit( &mdDataSum );
  4875.     MD4Translate( lpData, len, &mdDataSum );    
  4876.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4877.  
  4878.     return;
  4879. }
  4880.  
  4881.  
  4882. -------------- Include
  4883.  
  4884. #ifndef __windows_h__
  4885.         typedef unsigned long DWORD;
  4886.         #define STDCALL _stdcall
  4887. #endif
  4888.  
  4889. typedef struct 
  4890. {
  4891.     DWORD dwSum[4];
  4892. }MDxSum;
  4893.  
  4894. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  4895. void STDCALL MDxInit( MDxSum * );
  4896. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  4897. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  4898. const char * STDCALL MDxGetVersion();
  4899. void STDCALL MDxFinalize( MDxSum * );
  4900.  
  4901.  
  4902. #include "mdx.h"
  4903. #include <stdlib.h>
  4904. #include <stdio.h>
  4905. #include <string.h>
  4906.  
  4907. // READLEN % 64 must = 0
  4908. #define READLEN    1048576L // 2^20, 1MB
  4909.  
  4910. void DigestFile( char * );
  4911. void DigestString();
  4912.  
  4913. void main(int argc, char *argv[])
  4914. {
  4915.     printf("%s\n\n", MDxGetVersion());
  4916.  
  4917.     if( argc > 1 )
  4918.         DigestFile( argv[1] );
  4919.     else    
  4920.         DigestString();
  4921.  
  4922. }
  4923.  
  4924. /*
  4925.     I use the 'chunk' method for processing files not because of
  4926.     limitations of my dll, but think what would happen if you
  4927.     tried to load an entire cd image into memory.
  4928. */
  4929. void DigestFile( char *szFName )
  4930. {
  4931.     FILE *file;
  4932.     void *lpData;
  4933.     long flen, mlen;
  4934.     MDxSum mdDataSum;
  4935.     MDxSum md4DataSum;
  4936.  
  4937.     // the 64 is for padding purposes
  4938.     lpData = malloc( READLEN + 64 );
  4939.     
  4940.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  4941.  
  4942.     file = fopen( szFName, "rb" );
  4943.     if( file == NULL )
  4944.     {
  4945.         printf("ERROR: File not found.\n");
  4946.         return;
  4947.     }
  4948.     
  4949.     MDxInit( &mdDataSum );
  4950.     MDxInit( &md4DataSum );
  4951.     
  4952.     fseek( file, 0, SEEK_END );
  4953.     //Get the file length
  4954.     flen = mlen = ftell( file );
  4955.     fseek( file, 0, SEEK_SET );
  4956.     
  4957.     // When it takes a while to process a large file,
  4958.     // remember that for each chunk it has to run 
  4959.     // through the main translation loop 16384 times!
  4960.         
  4961.     printf("Processing %ld byte file: .", flen );
  4962.     
  4963.     while( flen > READLEN )
  4964.     {
  4965.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  4966.         {
  4967.             printf("READ ERROR!\n");
  4968.             return;
  4969.         }
  4970.         MD5Translate( lpData, READLEN, &mdDataSum );
  4971.         MD4Translate( lpData, READLEN, &md4DataSum );
  4972.         flen -= READLEN;
  4973.         printf(".");
  4974.     }
  4975.  
  4976.     if (fread( lpData, 1, flen, file ) != flen)
  4977.     {
  4978.         printf("READ ERROR!\n");
  4979.         return;
  4980.     }
  4981.     // This is why I added the new argument to MDxPad
  4982.     // So we can pass the length of the data AND the
  4983.     // Total length of the message
  4984.     // Also it now returns the # of padding bytes added,
  4985.     // this is for files that are an exact multiple of the chunk
  4986.     // length. (Otherwise the padding isn't Translated)
  4987.     flen += MDxPad( lpData, flen, mlen );
  4988.     MD5Translate( lpData, flen, &mdDataSum );    
  4989.     MD4Translate( lpData, flen, &md4DataSum );
  4990.  
  4991.     // New step necessary because of the 'chunking' method
  4992.     MDxFinalize( &mdDataSum );
  4993.     MDxFinalize( &md4DataSum );
  4994.     
  4995.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  4996.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  4997.     fclose(file);
  4998.         
  4999. }
  5000.  
  5001. void DigestString()
  5002. {
  5003.     
  5004.     //For our demo purposes, no strings bigger than 1024 :)
  5005.     unsigned char lpData[1024] = "";
  5006.     long len = 0;
  5007.     MDxSum mdDataSum;
  5008.  
  5009.     printf("Enter the string to digest: ");
  5010.     scanf("%s", &lpData );
  5011.     len = strlen(lpData);
  5012.     
  5013.     // Have to do this before the Padding...well...it's best anyway;)
  5014.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5015.     
  5016.     // For the strings, we're gonna pad and digest the string
  5017.     // in one pass.
  5018.     MDxInit( &mdDataSum );
  5019.     MDxPad( lpData, len, len );
  5020.     
  5021.     MD5Translate( lpData, len, &mdDataSum );
  5022.         // New step necessary because of the 'chunking' method
  5023.         MDxFinalize( &mdDataSum );
  5024.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5025.     
  5026.     MDxInit( &mdDataSum );
  5027.     MD4Translate( lpData, len, &mdDataSum );    
  5028.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5029.  
  5030.     return;
  5031. }
  5032.  
  5033.  
  5034. -------------- Include
  5035.  
  5036. #ifndef __windows_h__
  5037.         typedef unsigned long DWORD;
  5038.         #define STDCALL _stdcall
  5039. #endif
  5040.  
  5041. typedef struct 
  5042. {
  5043.     DWORD dwSum[4];
  5044. }MDxSum;
  5045.  
  5046. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5047. void STDCALL MDxInit( MDxSum * );
  5048. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5049. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5050. const char * STDCALL MDxGetVersion();
  5051. void STDCALL MDxFinalize( MDxSum * );
  5052.  
  5053.  
  5054. #include "mdx.h"
  5055. #include <stdlib.h>
  5056. #include <stdio.h>
  5057. #include <string.h>
  5058.  
  5059. // READLEN % 64 must = 0
  5060. #define READLEN    1048576L // 2^20, 1MB
  5061.  
  5062. void DigestFile( char * );
  5063. void DigestString();
  5064.  
  5065. void main(int argc, char *argv[])
  5066. {
  5067.     printf("%s\n\n", MDxGetVersion());
  5068.  
  5069.     if( argc > 1 )
  5070.         DigestFile( argv[1] );
  5071.     else    
  5072.         DigestString();
  5073.  
  5074. }
  5075.  
  5076. /*
  5077.     I use the 'chunk' method for processing files not because of
  5078.     limitations of my dll, but think what would happen if you
  5079.     tried to load an entire cd image into memory.
  5080. */
  5081. void DigestFile( char *szFName )
  5082. {
  5083.     FILE *file;
  5084.     void *lpData;
  5085.     long flen, mlen;
  5086.     MDxSum mdDataSum;
  5087.     MDxSum md4DataSum;
  5088.  
  5089.     // the 64 is for padding purposes
  5090.     lpData = malloc( READLEN + 64 );
  5091.     
  5092.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  5093.  
  5094.     file = fopen( szFName, "rb" );
  5095.     if( file == NULL )
  5096.     {
  5097.         printf("ERROR: File not found.\n");
  5098.         return;
  5099.     }
  5100.     
  5101.     MDxInit( &mdDataSum );
  5102.     MDxInit( &md4DataSum );
  5103.     
  5104.     fseek( file, 0, SEEK_END );
  5105.     //Get the file length
  5106.     flen = mlen = ftell( file );
  5107.     fseek( file, 0, SEEK_SET );
  5108.     
  5109.     // When it takes a while to process a large file,
  5110.     // remember that for each chunk it has to run 
  5111.     // through the main translation loop 16384 times!
  5112.         
  5113.     printf("Processing %ld byte file: .", flen );
  5114.     
  5115.     while( flen > READLEN )
  5116.     {
  5117.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  5118.         {
  5119.             printf("READ ERROR!\n");
  5120.             return;
  5121.         }
  5122.         MD5Translate( lpData, READLEN, &mdDataSum );
  5123.         MD4Translate( lpData, READLEN, &md4DataSum );
  5124.         flen -= READLEN;
  5125.         printf(".");
  5126.     }
  5127.  
  5128.     if (fread( lpData, 1, flen, file ) != flen)
  5129.     {
  5130.         printf("READ ERROR!\n");
  5131.         return;
  5132.     }
  5133.     // This is why I added the new argument to MDxPad
  5134.     // So we can pass the length of the data AND the
  5135.     // Total length of the message
  5136.     // Also it now returns the # of padding bytes added,
  5137.     // this is for files that are an exact multiple of the chunk
  5138.     // length. (Otherwise the padding isn't Translated)
  5139.     flen += MDxPad( lpData, flen, mlen );
  5140.     MD5Translate( lpData, flen, &mdDataSum );    
  5141.     MD4Translate( lpData, flen, &md4DataSum );
  5142.  
  5143.     // New step necessary because of the 'chunking' method
  5144.     MDxFinalize( &mdDataSum );
  5145.     MDxFinalize( &md4DataSum );
  5146.     
  5147.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  5148.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5149.     fclose(file);
  5150.         
  5151. }
  5152.  
  5153. void DigestString()
  5154. {
  5155.     
  5156.     //For our demo purposes, no strings bigger than 1024 :)
  5157.     unsigned char lpData[1024] = "";
  5158.     long len = 0;
  5159.     MDxSum mdDataSum;
  5160.  
  5161.     printf("Enter the string to digest: ");
  5162.     scanf("%s", &lpData );
  5163.     len = strlen(lpData);
  5164.     
  5165.     // Have to do this before the Padding...well...it's best anyway;)
  5166.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5167.     
  5168.     // For the strings, we're gonna pad and digest the string
  5169.     // in one pass.
  5170.     MDxInit( &mdDataSum );
  5171.     MDxPad( lpData, len, len );
  5172.     
  5173.     MD5Translate( lpData, len, &mdDataSum );
  5174.         // New step necessary because of the 'chunking' method
  5175.         MDxFinalize( &mdDataSum );
  5176.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5177.     
  5178.     MDxInit( &mdDataSum );
  5179.     MD4Translate( lpData, len, &mdDataSum );    
  5180.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5181.  
  5182.     return;
  5183. }
  5184.  
  5185.  
  5186. -------------- Include
  5187.  
  5188. #ifndef __windows_h__
  5189.         typedef unsigned long DWORD;
  5190.         #define STDCALL _stdcall
  5191. #endif
  5192.  
  5193. typedef struct 
  5194. {
  5195.     DWORD dwSum[4];
  5196. }MDxSum;
  5197.  
  5198. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5199. void STDCALL MDxInit( MDxSum * );
  5200. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5201. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5202. const char * STDCALL MDxGetVersion();
  5203. void STDCALL MDxFinalize( MDxSum * );
  5204.  
  5205. #include "mdx.h"
  5206. #include <stdlib.h>
  5207. #include <stdio.h>
  5208. #include <string.h>
  5209.  
  5210. // READLEN % 64 must = 0
  5211. #define READLEN    1048576L // 2^20, 1MB
  5212.  
  5213. void DigestFile( char * );
  5214. void DigestString();
  5215.  
  5216. void main(int argc, char *argv[])
  5217. {
  5218.     printf("%s\n\n", MDxGetVersion());
  5219.  
  5220.     if( argc > 1 )
  5221.         DigestFile( argv[1] );
  5222.     else    
  5223.         DigestString();
  5224.  
  5225. }
  5226.  
  5227. /*
  5228.     I use the 'chunk' method for processing files not because of
  5229.     limitations of my dll, but think what would happen if you
  5230.     tried to load an entire cd image into memory.
  5231. */
  5232. void DigestFile( char *szFName )
  5233. {
  5234.     FILE *file;
  5235.     void *lpData;
  5236.     long flen, mlen;
  5237.     MDxSum mdDataSum;
  5238.     MDxSum md4DataSum;
  5239.  
  5240.     // the 64 is for padding purposes
  5241.     lpData = malloc( READLEN + 64 );
  5242.     
  5243.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  5244.  
  5245.     file = fopen( szFName, "rb" );
  5246.     if( file == NULL )
  5247.     {
  5248.         printf("ERROR: File not found.\n");
  5249.         return;
  5250.     }
  5251.     
  5252.     MDxInit( &mdDataSum );
  5253.     MDxInit( &md4DataSum );
  5254.     
  5255.     fseek( file, 0, SEEK_END );
  5256.     //Get the file length
  5257.     flen = mlen = ftell( file );
  5258.     fseek( file, 0, SEEK_SET );
  5259.     
  5260.     // When it takes a while to process a large file,
  5261.     // remember that for each chunk it has to run 
  5262.     // through the main translation loop 16384 times!
  5263.         
  5264.     printf("Processing %ld byte file: .", flen );
  5265.     
  5266.     while( flen > READLEN )
  5267.     {
  5268.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  5269.         {
  5270.             printf("READ ERROR!\n");
  5271.             return;
  5272.         }
  5273.         MD5Translate( lpData, READLEN, &mdDataSum );
  5274.         MD4Translate( lpData, READLEN, &md4DataSum );
  5275.         flen -= READLEN;
  5276.         printf(".");
  5277.     }
  5278.  
  5279.     if (fread( lpData, 1, flen, file ) != flen)
  5280.     {
  5281.         printf("READ ERROR!\n");
  5282.         return;
  5283.     }
  5284.     // This is why I added the new argument to MDxPad
  5285.     // So we can pass the length of the data AND the
  5286.     // Total length of the message
  5287.     // Also it now returns the # of padding bytes added,
  5288.     // this is for files that are an exact multiple of the chunk
  5289.     // length. (Otherwise the padding isn't Translated)
  5290.     flen += MDxPad( lpData, flen, mlen );
  5291.     MD5Translate( lpData, flen, &mdDataSum );    
  5292.     MD4Translate( lpData, flen, &md4DataSum );
  5293.  
  5294.     // New step necessary because of the 'chunking' method
  5295.     MDxFinalize( &mdDataSum );
  5296.     MDxFinalize( &md4DataSum );
  5297.     
  5298.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  5299.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5300.     fclose(file);
  5301.         
  5302. }
  5303.  
  5304. void DigestString()
  5305. {
  5306.     
  5307.     //For our demo purposes, no strings bigger than 1024 :)
  5308.     unsigned char lpData[1024] = "";
  5309.     long len = 0;
  5310.     MDxSum mdDataSum;
  5311.  
  5312.     printf("Enter the string to digest: ");
  5313.     scanf("%s", &lpData );
  5314.     len = strlen(lpData);
  5315.     
  5316.     // Have to do this before the Padding...well...it's best anyway;)
  5317.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5318.     
  5319.     // For the strings, we're gonna pad and digest the string
  5320.     // in one pass.
  5321.     MDxInit( &mdDataSum );
  5322.     MDxPad( lpData, len, len );
  5323.     
  5324.     MD5Translate( lpData, len, &mdDataSum );
  5325.         // New step necessary because of the 'chunking' method
  5326.         MDxFinalize( &mdDataSum );
  5327.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5328.     
  5329.     MDxInit( &mdDataSum );
  5330.     MD4Translate( lpData, len, &mdDataSum );    
  5331.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5332.  
  5333.     return;
  5334. }
  5335.  
  5336.  
  5337. -------------- Include
  5338.  
  5339. #ifndef __windows_h__
  5340.         typedef unsigned long DWORD;
  5341.         #define STDCALL _stdcall
  5342. #endif
  5343.  
  5344. typedef struct 
  5345. {
  5346.     DWORD dwSum[4];
  5347. }MDxSum;
  5348.  
  5349. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5350. void STDCALL MDxInit( MDxSum * );
  5351. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5352. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5353. const char * STDCALL MDxGetVersion();
  5354. void STDCALL MDxFinalize( MDxSum * );
  5355.  
  5356.  
  5357.  
  5358. #include "mdx.h"
  5359. #include <stdlib.h>
  5360. #include <stdio.h>
  5361. #include <string.h>
  5362.  
  5363. // READLEN % 64 must = 0
  5364. #define READLEN    1048576L // 2^20, 1MB
  5365.  
  5366. void DigestFile( char * );
  5367. void DigestString();
  5368.  
  5369. void main(int argc, char *argv[])
  5370. {
  5371.     printf("%s\n\n", MDxGetVersion());
  5372.  
  5373.     if( argc > 1 )
  5374.         DigestFile( argv[1] );
  5375.     else    
  5376.         DigestString();
  5377.  
  5378. }
  5379.  
  5380. /*
  5381.     I use the 'chunk' method for processing files not because of
  5382.     limitations of my dll, but think what would happen if you
  5383.     tried to load an entire cd image into memory.
  5384. */
  5385. void DigestFile( char *szFName )
  5386. {
  5387.     FILE *file;
  5388.     void *lpData;
  5389.     long flen, mlen;
  5390.     MDxSum mdDataSum;
  5391.     MDxSum md4DataSum;
  5392.  
  5393.     // the 64 is for padding purposes
  5394.     lpData = malloc( READLEN + 64 );
  5395.     
  5396.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  5397.  
  5398.     file = fopen( szFName, "rb" );
  5399.     if( file == NULL )
  5400.     {
  5401.         printf("ERROR: File not found.\n");
  5402.         return;
  5403.     }
  5404.     
  5405.     MDxInit( &mdDataSum );
  5406.     MDxInit( &md4DataSum );
  5407.     
  5408.     fseek( file, 0, SEEK_END );
  5409.     //Get the file length
  5410.     flen = mlen = ftell( file );
  5411.     fseek( file, 0, SEEK_SET );
  5412.     
  5413.     // When it takes a while to process a large file,
  5414.     // remember that for each chunk it has to run 
  5415.     // through the main translation loop 16384 times!
  5416.         
  5417.     printf("Processing %ld byte file: .", flen );
  5418.     
  5419.     while( flen > READLEN )
  5420.     {
  5421.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  5422.         {
  5423.             printf("READ ERROR!\n");
  5424.             return;
  5425.         }
  5426.         MD5Translate( lpData, READLEN, &mdDataSum );
  5427.         MD4Translate( lpData, READLEN, &md4DataSum );
  5428.         flen -= READLEN;
  5429.         printf(".");
  5430.     }
  5431.  
  5432.     if (fread( lpData, 1, flen, file ) != flen)
  5433.     {
  5434.         printf("READ ERROR!\n");
  5435.         return;
  5436.     }
  5437.     // This is why I added the new argument to MDxPad
  5438.     // So we can pass the length of the data AND the
  5439.     // Total length of the message
  5440.     // Also it now returns the # of padding bytes added,
  5441.     // this is for files that are an exact multiple of the chunk
  5442.     // length. (Otherwise the padding isn't Translated)
  5443.     flen += MDxPad( lpData, flen, mlen );
  5444.     MD5Translate( lpData, flen, &mdDataSum );    
  5445.     MD4Translate( lpData, flen, &md4DataSum );
  5446.  
  5447.     // New step necessary because of the 'chunking' method
  5448.     MDxFinalize( &mdDataSum );
  5449.     MDxFinalize( &md4DataSum );
  5450.     
  5451.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  5452.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5453.     fclose(file);
  5454.         
  5455. }
  5456.  
  5457. void DigestString()
  5458. {
  5459.     
  5460.     //For our demo purposes, no strings bigger than 1024 :)
  5461.     unsigned char lpData[1024] = "";
  5462.     long len = 0;
  5463.     MDxSum mdDataSum;
  5464.  
  5465.     printf("Enter the string to digest: ");
  5466.     scanf("%s", &lpData );
  5467.     len = strlen(lpData);
  5468.     
  5469.     // Have to do this before the Padding...well...it's best anyway;)
  5470.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5471.     
  5472.     // For the strings, we're gonna pad and digest the string
  5473.     // in one pass.
  5474.     MDxInit( &mdDataSum );
  5475.     MDxPad( lpData, len, len );
  5476.     
  5477.     MD5Translate( lpData, len, &mdDataSum );
  5478.         // New step necessary because of the 'chunking' method
  5479.         MDxFinalize( &mdDataSum );
  5480.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5481.     
  5482.     MDxInit( &mdDataSum );
  5483.     MD4Translate( lpData, len, &mdDataSum );    
  5484.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5485.  
  5486.     return;
  5487. }
  5488.  
  5489.  
  5490. -------------- Include
  5491.  
  5492. #ifndef __windows_h__
  5493.         typedef unsigned long DWORD;
  5494.         #define STDCALL _stdcall
  5495. #endif
  5496.  
  5497. typedef struct 
  5498. {
  5499.     DWORD dwSum[4];
  5500. }MDxSum;
  5501.  
  5502. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5503. void STDCALL MDxInit( MDxSum * );
  5504. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5505. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5506. const char * STDCALL MDxGetVersion();
  5507. void STDCALL MDxFinalize( MDxSum * );
  5508.  
  5509.  
  5510.  
  5511. #include "mdx.h"
  5512. #include <stdlib.h>
  5513. #include <stdio.h>
  5514. #include <string.h>
  5515.  
  5516. // READLEN % 64 must = 0
  5517. #define READLEN    1048576L // 2^20, 1MB
  5518.  
  5519. void DigestFile( char * );
  5520. void DigestString();
  5521.  
  5522. void main(int argc, char *argv[])
  5523. {
  5524.     printf("%s\n\n", MDxGetVersion());
  5525.  
  5526.     if( argc > 1 )
  5527.         DigestFile( argv[1] );
  5528.     else    
  5529.         DigestString();
  5530.  
  5531. }
  5532.  
  5533. /*
  5534.     I use the 'chunk' method for processing files not because of
  5535.     limitations of my dll, but think what would happen if you
  5536.     tried to load an entire cd image into memory.
  5537. */
  5538. void DigestFile( char *szFName )
  5539. {
  5540.     FILE *file;
  5541.     void *lpData;
  5542.     long flen, mlen;
  5543.     MDxSum mdDataSum;
  5544.     MDxSum md4DataSum;
  5545.  
  5546.     // the 64 is for padding purposes
  5547.     lpData = malloc( READLEN + 64 );
  5548.     
  5549.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  5550.  
  5551.     file = fopen( szFName, "rb" );
  5552.     if( file == NULL )
  5553.     {
  5554.         printf("ERROR: File not found.\n");
  5555.         return;
  5556.     }
  5557.     
  5558.     MDxInit( &mdDataSum );
  5559.     MDxInit( &md4DataSum );
  5560.     
  5561.     fseek( file, 0, SEEK_END );
  5562.     //Get the file length
  5563.     flen = mlen = ftell( file );
  5564.     fseek( file, 0, SEEK_SET );
  5565.     
  5566.     // When it takes a while to process a large file,
  5567.     // remember that for each chunk it has to run 
  5568.     // through the main translation loop 16384 times!
  5569.         
  5570.     printf("Processing %ld byte file: .", flen );
  5571.     
  5572.     while( flen > READLEN )
  5573.     {
  5574.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  5575.         {
  5576.             printf("READ ERROR!\n");
  5577.             return;
  5578.         }
  5579.         MD5Translate( lpData, READLEN, &mdDataSum );
  5580.         MD4Translate( lpData, READLEN, &md4DataSum );
  5581.         flen -= READLEN;
  5582.         printf(".");
  5583.     }
  5584.  
  5585.     if (fread( lpData, 1, flen, file ) != flen)
  5586.     {
  5587.         printf("READ ERROR!\n");
  5588.         return;
  5589.     }
  5590.     // This is why I added the new argument to MDxPad
  5591.     // So we can pass the length of the data AND the
  5592.     // Total length of the message
  5593.     // Also it now returns the # of padding bytes added,
  5594.     // this is for files that are an exact multiple of the chunk
  5595.     // length. (Otherwise the padding isn't Translated)
  5596.     flen += MDxPad( lpData, flen, mlen );
  5597.     MD5Translate( lpData, flen, &mdDataSum );    
  5598.     MD4Translate( lpData, flen, &md4DataSum );
  5599.  
  5600.     // New step necessary because of the 'chunking' method
  5601.     MDxFinalize( &mdDataSum );
  5602.     MDxFinalize( &md4DataSum );
  5603.     
  5604.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  5605.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5606.     fclose(file);
  5607.         
  5608. }
  5609.  
  5610. void DigestString()
  5611. {
  5612.     
  5613.     //For our demo purposes, no strings bigger than 1024 :)
  5614.     unsigned char lpData[1024] = "";
  5615.     long len = 0;
  5616.     MDxSum mdDataSum;
  5617.  
  5618.     printf("Enter the string to digest: ");
  5619.     scanf("%s", &lpData );
  5620.     len = strlen(lpData);
  5621.     
  5622.     // Have to do this before the Padding...well...it's best anyway;)
  5623.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5624.     
  5625.     // For the strings, we're gonna pad and digest the string
  5626.     // in one pass.
  5627.     MDxInit( &mdDataSum );
  5628.     MDxPad( lpData, len, len );
  5629.     
  5630.     MD5Translate( lpData, len, &mdDataSum );
  5631.         // New step necessary because of the 'chunking' method
  5632.         MDxFinalize( &mdDataSum );
  5633.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5634.     
  5635.     MDxInit( &mdDataSum );
  5636.     MD4Translate( lpData, len, &mdDataSum );    
  5637.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5638.  
  5639.     return;
  5640. }
  5641.  
  5642.  
  5643. -------------- Include
  5644.  
  5645. #ifndef __windows_h__
  5646.         typedef unsigned long DWORD;
  5647.         #define STDCALL _stdcall
  5648. #endif
  5649.  
  5650. typedef struct 
  5651. {
  5652.     DWORD dwSum[4];
  5653. }MDxSum;
  5654.  
  5655. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5656. void STDCALL MDxInit( MDxSum * );
  5657. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5658. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5659. const char * STDCALL MDxGetVersion();
  5660. void STDCALL MDxFinalize( MDxSum * );
  5661.  
  5662.  
  5663.  
  5664. #include "mdx.h"
  5665. #include <stdlib.h>
  5666. #include <stdio.h>
  5667. #include <string.h>
  5668.  
  5669. // READLEN % 64 must = 0
  5670. #define READLEN    1048576L // 2^20, 1MB
  5671.  
  5672. void DigestFile( char * );
  5673. void DigestString();
  5674.  
  5675. void main(int argc, char *argv[])
  5676. {
  5677.     printf("%s\n\n", MDxGetVersion());
  5678.  
  5679.     if( argc > 1 )
  5680.         DigestFile( argv[1] );
  5681.     else    
  5682.         DigestString();
  5683.  
  5684. }
  5685.  
  5686. /*
  5687.     I use the 'chunk' method for processing files not because of
  5688.     limitations of my dll, but think what would happen if you
  5689.     tried to load an entire cd image into memory.
  5690. */
  5691. void DigestFile( char *szFName )
  5692. {
  5693.     FILE *file;
  5694.     void *lpData;
  5695.     long flen, mlen;
  5696.     MDxSum mdDataSum;
  5697.     MDxSum md4DataSum;
  5698.  
  5699.     // the 64 is for padding purposes
  5700.     lpData = malloc( READLEN + 64 );
  5701.     
  5702.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  5703.  
  5704.     file = fopen( szFName, "rb" );
  5705.     if( file == NULL )
  5706.     {
  5707.         printf("ERROR: File not found.\n");
  5708.         return;
  5709.     }
  5710.     
  5711.     MDxInit( &mdDataSum );
  5712.     MDxInit( &md4DataSum );
  5713.     
  5714.     fseek( file, 0, SEEK_END );
  5715.     //Get the file length
  5716.     flen = mlen = ftell( file );
  5717.     fseek( file, 0, SEEK_SET );
  5718.     
  5719.     // When it takes a while to process a large file,
  5720.     // remember that for each chunk it has to run 
  5721.     // through the main translation loop 16384 times!
  5722.         
  5723.     printf("Processing %ld byte file: .", flen );
  5724.     
  5725.     while( flen > READLEN )
  5726.     {
  5727.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  5728.         {
  5729.             printf("READ ERROR!\n");
  5730.             return;
  5731.         }
  5732.         MD5Translate( lpData, READLEN, &mdDataSum );
  5733.         MD4Translate( lpData, READLEN, &md4DataSum );
  5734.         flen -= READLEN;
  5735.         printf(".");
  5736.     }
  5737.  
  5738.     if (fread( lpData, 1, flen, file ) != flen)
  5739.     {
  5740.         printf("READ ERROR!\n");
  5741.         return;
  5742.     }
  5743.     // This is why I added the new argument to MDxPad
  5744.     // So we can pass the length of the data AND the
  5745.     // Total length of the message
  5746.     // Also it now returns the # of padding bytes added,
  5747.     // this is for files that are an exact multiple of the chunk
  5748.     // length. (Otherwise the padding isn't Translated)
  5749.     flen += MDxPad( lpData, flen, mlen );
  5750.     MD5Translate( lpData, flen, &mdDataSum );    
  5751.     MD4Translate( lpData, flen, &md4DataSum );
  5752.  
  5753.     // New step necessary because of the 'chunking' method
  5754.     MDxFinalize( &mdDataSum );
  5755.     MDxFinalize( &md4DataSum );
  5756.     
  5757.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  5758.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5759.     fclose(file);
  5760.         
  5761. }
  5762.  
  5763. void DigestString()
  5764. {
  5765.     
  5766.     //For our demo purposes, no strings bigger than 1024 :)
  5767.     unsigned char lpData[1024] = "";
  5768.     long len = 0;
  5769.     MDxSum mdDataSum;
  5770.  
  5771.     printf("Enter the string to digest: ");
  5772.     scanf("%s", &lpData );
  5773.     len = strlen(lpData);
  5774.     
  5775.     // Have to do this before the Padding...well...it's best anyway;)
  5776.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5777.     
  5778.     // For the strings, we're gonna pad and digest the string
  5779.     // in one pass.
  5780.     MDxInit( &mdDataSum );
  5781.     MDxPad( lpData, len, len );
  5782.     
  5783.     MD5Translate( lpData, len, &mdDataSum );
  5784.         // New step necessary because of the 'chunking' method
  5785.         MDxFinalize( &mdDataSum );
  5786.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5787.     
  5788.     MDxInit( &mdDataSum );
  5789.     MD4Translate( lpData, len, &mdDataSum );    
  5790.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5791.  
  5792.     return;
  5793. }
  5794.  
  5795.  
  5796. -------------- Include
  5797.  
  5798. #ifndef __windows_h__
  5799.         typedef unsigned long DWORD;
  5800.         #define STDCALL _stdcall
  5801. #endif
  5802.  
  5803. typedef struct 
  5804. {
  5805.     DWORD dwSum[4];
  5806. }MDxSum;
  5807.  
  5808. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5809. void STDCALL MDxInit( MDxSum * );
  5810. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5811. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5812. const char * STDCALL MDxGetVersion();
  5813. void STDCALL MDxFinalize( MDxSum * );
  5814.  
  5815.  
  5816.  
  5817. #include "mdx.h"
  5818. #include <stdlib.h>
  5819. #include <stdio.h>
  5820. #include <string.h>
  5821.  
  5822. // READLEN % 64 must = 0
  5823. #define READLEN    1048576L // 2^20, 1MB
  5824.  
  5825. void DigestFile( char * );
  5826. void DigestString();
  5827.  
  5828. void main(int argc, char *argv[])
  5829. {
  5830.     printf("%s\n\n", MDxGetVersion());
  5831.  
  5832.     if( argc > 1 )
  5833.         DigestFile( argv[1] );
  5834.     else    
  5835.         DigestString();
  5836.  
  5837. }
  5838.  
  5839. /*
  5840.     I use the 'chunk' method for processing files not because of
  5841.     limitations of my dll, but think what would happen if you
  5842.     tried to load an entire cd image into memory.
  5843. */
  5844. void DigestFile( char *szFName )
  5845. {
  5846.     FILE *file;
  5847.     void *lpData;
  5848.     long flen, mlen;
  5849.     MDxSum mdDataSum;
  5850.     MDxSum md4DataSum;
  5851.  
  5852.     // the 64 is for padding purposes
  5853.     lpData = malloc( READLEN + 64 );
  5854.     
  5855.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  5856.  
  5857.     file = fopen( szFName, "rb" );
  5858.     if( file == NULL )
  5859.     {
  5860.         printf("ERROR: File not found.\n");
  5861.         return;
  5862.     }
  5863.     
  5864.     MDxInit( &mdDataSum );
  5865.     MDxInit( &md4DataSum );
  5866.     
  5867.     fseek( file, 0, SEEK_END );
  5868.     //Get the file length
  5869.     flen = mlen = ftell( file );
  5870.     fseek( file, 0, SEEK_SET );
  5871.     
  5872.     // When it takes a while to process a large file,
  5873.     // remember that for each chunk it has to run 
  5874.     // through the main translation loop 16384 times!
  5875.         
  5876.     printf("Processing %ld byte file: .", flen );
  5877.     
  5878.     while( flen > READLEN )
  5879.     {
  5880.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  5881.         {
  5882.             printf("READ ERROR!\n");
  5883.             return;
  5884.         }
  5885.         MD5Translate( lpData, READLEN, &mdDataSum );
  5886.         MD4Translate( lpData, READLEN, &md4DataSum );
  5887.         flen -= READLEN;
  5888.         printf(".");
  5889.     }
  5890.  
  5891.     if (fread( lpData, 1, flen, file ) != flen)
  5892.     {
  5893.         printf("READ ERROR!\n");
  5894.         return;
  5895.     }
  5896.     // This is why I added the new argument to MDxPad
  5897.     // So we can pass the length of the data AND the
  5898.     // Total length of the message
  5899.     // Also it now returns the # of padding bytes added,
  5900.     // this is for files that are an exact multiple of the chunk
  5901.     // length. (Otherwise the padding isn't Translated)
  5902.     flen += MDxPad( lpData, flen, mlen );
  5903.     MD5Translate( lpData, flen, &mdDataSum );    
  5904.     MD4Translate( lpData, flen, &md4DataSum );
  5905.  
  5906.     // New step necessary because of the 'chunking' method
  5907.     MDxFinalize( &mdDataSum );
  5908.     MDxFinalize( &md4DataSum );
  5909.     
  5910.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  5911.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5912.     fclose(file);
  5913.         
  5914. }
  5915.  
  5916. void DigestString()
  5917. {
  5918.     
  5919.     //For our demo purposes, no strings bigger than 1024 :)
  5920.     unsigned char lpData[1024] = "";
  5921.     long len = 0;
  5922.     MDxSum mdDataSum;
  5923.  
  5924.     printf("Enter the string to digest: ");
  5925.     scanf("%s", &lpData );
  5926.     len = strlen(lpData);
  5927.     
  5928.     // Have to do this before the Padding...well...it's best anyway;)
  5929.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  5930.     
  5931.     // For the strings, we're gonna pad and digest the string
  5932.     // in one pass.
  5933.     MDxInit( &mdDataSum );
  5934.     MDxPad( lpData, len, len );
  5935.     
  5936.     MD5Translate( lpData, len, &mdDataSum );
  5937.         // New step necessary because of the 'chunking' method
  5938.         MDxFinalize( &mdDataSum );
  5939.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5940.     
  5941.     MDxInit( &mdDataSum );
  5942.     MD4Translate( lpData, len, &mdDataSum );    
  5943.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  5944.  
  5945.     return;
  5946. }
  5947.  
  5948.  
  5949. -------------- Include
  5950.  
  5951. #ifndef __windows_h__
  5952.         typedef unsigned long DWORD;
  5953.         #define STDCALL _stdcall
  5954. #endif
  5955.  
  5956. typedef struct 
  5957. {
  5958.     DWORD dwSum[4];
  5959. }MDxSum;
  5960.  
  5961. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  5962. void STDCALL MDxInit( MDxSum * );
  5963. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  5964. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  5965. const char * STDCALL MDxGetVersion();
  5966. void STDCALL MDxFinalize( MDxSum * );
  5967.  
  5968.  
  5969.  
  5970.  
  5971. #include "mdx.h"
  5972. #include <stdlib.h>
  5973. #include <stdio.h>
  5974. #include <string.h>
  5975.  
  5976. // READLEN % 64 must = 0
  5977. #define READLEN    1048576L // 2^20, 1MB
  5978.  
  5979. void DigestFile( char * );
  5980. void DigestString();
  5981.  
  5982. void main(int argc, char *argv[])
  5983. {
  5984.     printf("%s\n\n", MDxGetVersion());
  5985.  
  5986.     if( argc > 1 )
  5987.         DigestFile( argv[1] );
  5988.     else    
  5989.         DigestString();
  5990.  
  5991. }
  5992.  
  5993. /*
  5994.     I use the 'chunk' method for processing files not because of
  5995.     limitations of my dll, but think what would happen if you
  5996.     tried to load an entire cd image into memory.
  5997. */
  5998. void DigestFile( char *szFName )
  5999. {
  6000.     FILE *file;
  6001.     void *lpData;
  6002.     long flen, mlen;
  6003.     MDxSum mdDataSum;
  6004.     MDxSum md4DataSum;
  6005.  
  6006.     // the 64 is for padding purposes
  6007.     lpData = malloc( READLEN + 64 );
  6008.     
  6009.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6010.  
  6011.     file = fopen( szFName, "rb" );
  6012.     if( file == NULL )
  6013.     {
  6014.         printf("ERROR: File not found.\n");
  6015.         return;
  6016.     }
  6017.     
  6018.     MDxInit( &mdDataSum );
  6019.     MDxInit( &md4DataSum );
  6020.     
  6021.     fseek( file, 0, SEEK_END );
  6022.     //Get the file length
  6023.     flen = mlen = ftell( file );
  6024.     fseek( file, 0, SEEK_SET );
  6025.     
  6026.     // When it takes a while to process a large file,
  6027.     // remember that for each chunk it has to run 
  6028.     // through the main translation loop 16384 times!
  6029.         
  6030.     printf("Processing %ld byte file: .", flen );
  6031.     
  6032.     while( flen > READLEN )
  6033.     {
  6034.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6035.         {
  6036.             printf("READ ERROR!\n");
  6037.             return;
  6038.         }
  6039.         MD5Translate( lpData, READLEN, &mdDataSum );
  6040.         MD4Translate( lpData, READLEN, &md4DataSum );
  6041.         flen -= READLEN;
  6042.         printf(".");
  6043.     }
  6044.  
  6045.     if (fread( lpData, 1, flen, file ) != flen)
  6046.     {
  6047.         printf("READ ERROR!\n");
  6048.         return;
  6049.     }
  6050.     // This is why I added the new argument to MDxPad
  6051.     // So we can pass the length of the data AND the
  6052.     // Total length of the message
  6053.     // Also it now returns the # of padding bytes added,
  6054.     // this is for files that are an exact multiple of the chunk
  6055.     // length. (Otherwise the padding isn't Translated)
  6056.     flen += MDxPad( lpData, flen, mlen );
  6057.     MD5Translate( lpData, flen, &mdDataSum );    
  6058.     MD4Translate( lpData, flen, &md4DataSum );
  6059.  
  6060.     // New step necessary because of the 'chunking' method
  6061.     MDxFinalize( &mdDataSum );
  6062.     MDxFinalize( &md4DataSum );
  6063.     
  6064.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6065.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6066.     fclose(file);
  6067.         
  6068. }
  6069.  
  6070. void DigestString()
  6071. {
  6072.     
  6073.     //For our demo purposes, no strings bigger than 1024 :)
  6074.     unsigned char lpData[1024] = "";
  6075.     long len = 0;
  6076.     MDxSum mdDataSum;
  6077.  
  6078.     printf("Enter the string to digest: ");
  6079.     scanf("%s", &lpData );
  6080.     len = strlen(lpData);
  6081.     
  6082.     // Have to do this before the Padding...well...it's best anyway;)
  6083.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  6084.     
  6085.     // For the strings, we're gonna pad and digest the string
  6086.     // in one pass.
  6087.     MDxInit( &mdDataSum );
  6088.     MDxPad( lpData, len, len );
  6089.     
  6090.     MD5Translate( lpData, len, &mdDataSum );
  6091.         // New step necessary because of the 'chunking' method
  6092.         MDxFinalize( &mdDataSum );
  6093.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6094.     
  6095.     MDxInit( &mdDataSum );
  6096.     MD4Translate( lpData, len, &mdDataSum );    
  6097.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6098.  
  6099.     return;
  6100. }
  6101.  
  6102.  
  6103. -------------- Include
  6104.  
  6105. #ifndef __windows_h__
  6106.         typedef unsigned long DWORD;
  6107.         #define STDCALL _stdcall
  6108. #endif
  6109.  
  6110. typedef struct 
  6111. {
  6112.     DWORD dwSum[4];
  6113. }MDxSum;
  6114.  
  6115. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  6116. void STDCALL MDxInit( MDxSum * );
  6117. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  6118. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  6119. const char * STDCALL MDxGetVersion();
  6120. void STDCALL MDxFinalize( MDxSum * );
  6121.  
  6122.  
  6123.  
  6124.  
  6125. #include "mdx.h"
  6126. #include <stdlib.h>
  6127. #include <stdio.h>
  6128. #include <string.h>
  6129.  
  6130. // READLEN % 64 must = 0
  6131. #define READLEN    1048576L // 2^20, 1MB
  6132.  
  6133. void DigestFile( char * );
  6134. void DigestString();
  6135.  
  6136. void main(int argc, char *argv[])
  6137. {
  6138.     printf("%s\n\n", MDxGetVersion());
  6139.  
  6140.     if( argc > 1 )
  6141.         DigestFile( argv[1] );
  6142.     else    
  6143.         DigestString();
  6144.  
  6145. }
  6146.  
  6147. /*
  6148.     I use the 'chunk' method for processing files not because of
  6149.     limitations of my dll, but think what would happen if you
  6150.     tried to load an entire cd image into memory.
  6151. */
  6152. void DigestFile( char *szFName )
  6153. {
  6154.     FILE *file;
  6155.     void *lpData;
  6156.     long flen, mlen;
  6157.     MDxSum mdDataSum;
  6158.     MDxSum md4DataSum;
  6159.  
  6160.     // the 64 is for padding purposes
  6161.     lpData = malloc( READLEN + 64 );
  6162.     
  6163.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6164.  
  6165.     file = fopen( szFName, "rb" );
  6166.     if( file == NULL )
  6167.     {
  6168.         printf("ERROR: File not found.\n");
  6169.         return;
  6170.     }
  6171.     
  6172.     MDxInit( &mdDataSum );
  6173.     MDxInit( &md4DataSum );
  6174.     
  6175.     fseek( file, 0, SEEK_END );
  6176.     //Get the file length
  6177.     flen = mlen = ftell( file );
  6178.     fseek( file, 0, SEEK_SET );
  6179.     
  6180.     // When it takes a while to process a large file,
  6181.     // remember that for each chunk it has to run 
  6182.     // through the main translation loop 16384 times!
  6183.         
  6184.     printf("Processing %ld byte file: .", flen );
  6185.     
  6186.     while( flen > READLEN )
  6187.     {
  6188.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6189.         {
  6190.             printf("READ ERROR!\n");
  6191.             return;
  6192.         }
  6193.         MD5Translate( lpData, READLEN, &mdDataSum );
  6194.         MD4Translate( lpData, READLEN, &md4DataSum );
  6195.         flen -= READLEN;
  6196.         printf(".");
  6197.     }
  6198.  
  6199.     if (fread( lpData, 1, flen, file ) != flen)
  6200.     {
  6201.         printf("READ ERROR!\n");
  6202.         return;
  6203.     }
  6204.     // This is why I added the new argument to MDxPad
  6205.     // So we can pass the length of the data AND the
  6206.     // Total length of the message
  6207.     // Also it now returns the # of padding bytes added,
  6208.     // this is for files that are an exact multiple of the chunk
  6209.     // length. (Otherwise the padding isn't Translated)
  6210.     flen += MDxPad( lpData, flen, mlen );
  6211.     MD5Translate( lpData, flen, &mdDataSum );    
  6212.     MD4Translate( lpData, flen, &md4DataSum );
  6213.  
  6214.     // New step necessary because of the 'chunking' method
  6215.     MDxFinalize( &mdDataSum );
  6216.     MDxFinalize( &md4DataSum );
  6217.     
  6218.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6219.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6220.     fclose(file);
  6221.         
  6222. }
  6223.  
  6224. void DigestString()
  6225. {
  6226.     
  6227.     //For our demo purposes, no strings bigger than 1024 :)
  6228.     unsigned char lpData[1024] = "";
  6229.     long len = 0;
  6230.     MDxSum mdDataSum;
  6231.  
  6232.     printf("Enter the string to digest: ");
  6233.     scanf("%s", &lpData );
  6234.     len = strlen(lpData);
  6235.     
  6236.     // Have to do this before the Padding...well...it's best anyway;)
  6237.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  6238.     
  6239.     // For the strings, we're gonna pad and digest the string
  6240.     // in one pass.
  6241.     MDxInit( &mdDataSum );
  6242.     MDxPad( lpData, len, len );
  6243.     
  6244.     MD5Translate( lpData, len, &mdDataSum );
  6245.         // New step necessary because of the 'chunking' method
  6246.         MDxFinalize( &mdDataSum );
  6247.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6248.     
  6249.     MDxInit( &mdDataSum );
  6250.     MD4Translate( lpData, len, &mdDataSum );    
  6251.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6252.  
  6253.     return;
  6254. }
  6255.  
  6256.  
  6257. -------------- Include
  6258.  
  6259. #ifndef __windows_h__
  6260.         typedef unsigned long DWORD;
  6261.         #define STDCALL _stdcall
  6262. #endif
  6263.  
  6264. typedef struct 
  6265. {
  6266.     DWORD dwSum[4];
  6267. }MDxSum;
  6268.  
  6269. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  6270. void STDCALL MDxInit( MDxSum * );
  6271. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  6272. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  6273. const char * STDCALL MDxGetVersion();
  6274. void STDCALL MDxFinalize( MDxSum * );
  6275.  
  6276.  
  6277.  
  6278.  
  6279. #include "mdx.h"
  6280. #include <stdlib.h>
  6281. #include <stdio.h>
  6282. #include <string.h>
  6283.  
  6284. // READLEN % 64 must = 0
  6285. #define READLEN    1048576L // 2^20, 1MB
  6286.  
  6287. void DigestFile( char * );
  6288. void DigestString();
  6289.  
  6290. void main(int argc, char *argv[])
  6291. {
  6292.     printf("%s\n\n", MDxGetVersion());
  6293.  
  6294.     if( argc > 1 )
  6295.         DigestFile( argv[1] );
  6296.     else    
  6297.         DigestString();
  6298.  
  6299. }
  6300.  
  6301. /*
  6302.     I use the 'chunk' method for processing files not because of
  6303.     limitations of my dll, but think what would happen if you
  6304.     tried to load an entire cd image into memory.
  6305. */
  6306. void DigestFile( char *szFName )
  6307. {
  6308.     FILE *file;
  6309.     void *lpData;
  6310.     long flen, mlen;
  6311.     MDxSum mdDataSum;
  6312.     MDxSum md4DataSum;
  6313.  
  6314.     // the 64 is for padding purposes
  6315.     lpData = malloc( READLEN + 64 );
  6316.     
  6317.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6318.  
  6319.     file = fopen( szFName, "rb" );
  6320.     if( file == NULL )
  6321.     {
  6322.         printf("ERROR: File not found.\n");
  6323.         return;
  6324.     }
  6325.     
  6326.     MDxInit( &mdDataSum );
  6327.     MDxInit( &md4DataSum );
  6328.     
  6329.     fseek( file, 0, SEEK_END );
  6330.     //Get the file length
  6331.     flen = mlen = ftell( file );
  6332.     fseek( file, 0, SEEK_SET );
  6333.     
  6334.     // When it takes a while to process a large file,
  6335.     // remember that for each chunk it has to run 
  6336.     // through the main translation loop 16384 times!
  6337.         
  6338.     printf("Processing %ld byte file: .", flen );
  6339.     
  6340.     while( flen > READLEN )
  6341.     {
  6342.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6343.         {
  6344.             printf("READ ERROR!\n");
  6345.             return;
  6346.         }
  6347.         MD5Translate( lpData, READLEN, &mdDataSum );
  6348.         MD4Translate( lpData, READLEN, &md4DataSum );
  6349.         flen -= READLEN;
  6350.         printf(".");
  6351.     }
  6352.  
  6353.     if (fread( lpData, 1, flen, file ) != flen)
  6354.     {
  6355.         printf("READ ERROR!\n");
  6356.         return;
  6357.     }
  6358.     // This is why I added the new argument to MDxPad
  6359.     // So we can pass the length of the data AND the
  6360.     // Total length of the message
  6361.     // Also it now returns the # of padding bytes added,
  6362.     // this is for files that are an exact multiple of the chunk
  6363.     // length. (Otherwise the padding isn't Translated)
  6364.     flen += MDxPad( lpData, flen, mlen );
  6365.     MD5Translate( lpData, flen, &mdDataSum );    
  6366.     MD4Translate( lpData, flen, &md4DataSum );
  6367.  
  6368.     // New step necessary because of the 'chunking' method
  6369.     MDxFinalize( &mdDataSum );
  6370.     MDxFinalize( &md4DataSum );
  6371.     
  6372.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6373.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6374.     fclose(file);
  6375.         
  6376. }
  6377.  
  6378. void DigestString()
  6379. {
  6380.     
  6381.     //For our demo purposes, no strings bigger than 1024 :)
  6382.     unsigned char lpData[1024] = "";
  6383.     long len = 0;
  6384.     MDxSum mdDataSum;
  6385.  
  6386.     printf("Enter the string to digest: ");
  6387.     scanf("%s", &lpData );
  6388.     len = strlen(lpData);
  6389.     
  6390.     // Have to do this before the Padding...well...it's best anyway;)
  6391.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  6392.     
  6393.     // For the strings, we're gonna pad and digest the string
  6394.     // in one pass.
  6395.     MDxInit( &mdDataSum );
  6396.     MDxPad( lpData, len, len );
  6397.     
  6398.     MD5Translate( lpData, len, &mdDataSum );
  6399.         // New step necessary because of the 'chunking' method
  6400.         MDxFinalize( &mdDataSum );
  6401.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6402.     
  6403.     MDxInit( &mdDataSum );
  6404.     MD4Translate( lpData, len, &mdDataSum );    
  6405.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6406.  
  6407.     return;
  6408. }
  6409.  
  6410.  
  6411. -------------- Include
  6412.  
  6413. #ifndef __windows_h__
  6414.         typedef unsigned long DWORD;
  6415.         #define STDCALL _stdcall
  6416. #endif
  6417.  
  6418. typedef struct 
  6419. {
  6420.     DWORD dwSum[4];
  6421. }MDxSum;
  6422.  
  6423. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  6424. void STDCALL MDxInit( MDxSum * );
  6425. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  6426. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  6427. const char * STDCALL MDxGetVersion();
  6428. void STDCALL MDxFinalize( MDxSum * );
  6429.  
  6430.  
  6431.  
  6432. #include "mdx.h"
  6433. #include <stdlib.h>
  6434. #include <stdio.h>
  6435. #include <string.h>
  6436.  
  6437. // READLEN % 64 must = 0
  6438. #define READLEN    1048576L // 2^20, 1MB
  6439.  
  6440. void DigestFile( char * );
  6441. void DigestString();
  6442.  
  6443. void main(int argc, char *argv[])
  6444. {
  6445.     printf("%s\n\n", MDxGetVersion());
  6446.  
  6447.     if( argc > 1 )
  6448.         DigestFile( argv[1] );
  6449.     else    
  6450.         DigestString();
  6451.  
  6452. }
  6453.  
  6454. /*
  6455.     I use the 'chunk' method for processing files not because of
  6456.     limitations of my dll, but think what would happen if you
  6457.     tried to load an entire cd image into memory.
  6458. */
  6459. void DigestFile( char *szFName )
  6460. {
  6461.     FILE *file;
  6462.     void *lpData;
  6463.     long flen, mlen;
  6464.     MDxSum mdDataSum;
  6465.     MDxSum md4DataSum;
  6466.  
  6467.     // the 64 is for padding purposes
  6468.     lpData = malloc( READLEN + 64 );
  6469.     
  6470.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6471.  
  6472.     file = fopen( szFName, "rb" );
  6473.     if( file == NULL )
  6474.     {
  6475.         printf("ERROR: File not found.\n");
  6476.         return;
  6477.     }
  6478.     
  6479.     MDxInit( &mdDataSum );
  6480.     MDxInit( &md4DataSum );
  6481.     
  6482.     fseek( file, 0, SEEK_END );
  6483.     //Get the file length
  6484.     flen = mlen = ftell( file );
  6485.     fseek( file, 0, SEEK_SET );
  6486.     
  6487.     // When it takes a while to process a large file,
  6488.     // remember that for each chunk it has to run 
  6489.     // through the main translation loop 16384 times!
  6490.         
  6491.     printf("Processing %ld byte file: .", flen );
  6492.     
  6493.     while( flen > READLEN )
  6494.     {
  6495.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6496.         {
  6497.             printf("READ ERROR!\n");
  6498.             return;
  6499.         }
  6500.         MD5Translate( lpData, READLEN, &mdDataSum );
  6501.         MD4Translate( lpData, READLEN, &md4DataSum );
  6502.         flen -= READLEN;
  6503.         printf(".");
  6504.     }
  6505.  
  6506.     if (fread( lpData, 1, flen, file ) != flen)
  6507.     {
  6508.         printf("READ ERROR!\n");
  6509.         return;
  6510.     }
  6511.     // This is why I added the new argument to MDxPad
  6512.     // So we can pass the length of the data AND the
  6513.     // Total length of the message
  6514.     // Also it now returns the # of padding bytes added,
  6515.     // this is for files that are an exact multiple of the chunk
  6516.     // length. (Otherwise the padding isn't Translated)
  6517.     flen += MDxPad( lpData, flen, mlen );
  6518.     MD5Translate( lpData, flen, &mdDataSum );    
  6519.     MD4Translate( lpData, flen, &md4DataSum );
  6520.  
  6521.     // New step necessary because of the 'chunking' method
  6522.     MDxFinalize( &mdDataSum );
  6523.     MDxFinalize( &md4DataSum );
  6524.     
  6525.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6526.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6527.     fclose(file);
  6528.         
  6529. }
  6530.  
  6531. void DigestString()
  6532. {
  6533.     
  6534.     //For our demo purposes, no strings bigger than 1024 :)
  6535.     unsigned char lpData[1024] = "";
  6536.     long len = 0;
  6537.     MDxSum mdDataSum;
  6538.  
  6539.     printf("Enter the string to digest: ");
  6540.     scanf("%s", &lpData );
  6541.     len = strlen(lpData);
  6542.     
  6543.     // Have to do this before the Padding...well...it's best anyway;)
  6544.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  6545.     
  6546.     // For the strings, we're gonna pad and digest the string
  6547.     // in one pass.
  6548.     MDxInit( &mdDataSum );
  6549.     MDxPad( lpData, len, len );
  6550.     
  6551.     MD5Translate( lpData, len, &mdDataSum );
  6552.         // New step necessary because of the 'chunking' method
  6553.         MDxFinalize( &mdDataSum );
  6554.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6555.     
  6556.     MDxInit( &mdDataSum );
  6557.     MD4Translate( lpData, len, &mdDataSum );    
  6558.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6559.  
  6560.     return;
  6561. }
  6562.  
  6563.  
  6564. -------------- Include
  6565.  
  6566. #ifndef __windows_h__
  6567.         typedef unsigned long DWORD;
  6568.         #define STDCALL _stdcall
  6569. #endif
  6570.  
  6571. typedef struct 
  6572. {
  6573.     DWORD dwSum[4];
  6574. }MDxSum;
  6575.  
  6576. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  6577. void STDCALL MDxInit( MDxSum * );
  6578. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  6579. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  6580. const char * STDCALL MDxGetVersion();
  6581. void STDCALL MDxFinalize( MDxSum * );
  6582.  
  6583.  
  6584.  
  6585. #include "mdx.h"
  6586. #include <stdlib.h>
  6587. #include <stdio.h>
  6588. #include <string.h>
  6589.  
  6590. // READLEN % 64 must = 0
  6591. #define READLEN    1048576L // 2^20, 1MB
  6592.  
  6593. void DigestFile( char * );
  6594. void DigestString();
  6595.  
  6596. void main(int argc, char *argv[])
  6597. {
  6598.     printf("%s\n\n", MDxGetVersion());
  6599.  
  6600.     if( argc > 1 )
  6601.         DigestFile( argv[1] );
  6602.     else    
  6603.         DigestString();
  6604.  
  6605. }
  6606.  
  6607. /*
  6608.     I use the 'chunk' method for processing files not because of
  6609.     limitations of my dll, but think what would happen if you
  6610.     tried to load an entire cd image into memory.
  6611. */
  6612. void DigestFile( char *szFName )
  6613. {
  6614.     FILE *file;
  6615.     void *lpData;
  6616.     long flen, mlen;
  6617.     MDxSum mdDataSum;
  6618.     MDxSum md4DataSum;
  6619.  
  6620.     // the 64 is for padding purposes
  6621.     lpData = malloc( READLEN + 64 );
  6622.     
  6623.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6624.  
  6625.     file = fopen( szFName, "rb" );
  6626.     if( file == NULL )
  6627.     {
  6628.         printf("ERROR: File not found.\n");
  6629.         return;
  6630.     }
  6631.     
  6632.     MDxInit( &mdDataSum );
  6633.     MDxInit( &md4DataSum );
  6634.     
  6635.     fseek( file, 0, SEEK_END );
  6636.     //Get the file length
  6637.     flen = mlen = ftell( file );
  6638.     fseek( file, 0, SEEK_SET );
  6639.     
  6640.     // When it takes a while to process a large file,
  6641.     // remember that for each chunk it has to run 
  6642.     // through the main translation loop 16384 times!
  6643.         
  6644.     printf("Processing %ld byte file: .", flen );
  6645.     
  6646.     while( flen > READLEN )
  6647.     {
  6648.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6649.         {
  6650.             printf("READ ERROR!\n");
  6651.             return;
  6652.         }
  6653.         MD5Translate( lpData, READLEN, &mdDataSum );
  6654.         MD4Translate( lpData, READLEN, &md4DataSum );
  6655.         flen -= READLEN;
  6656.         printf(".");
  6657.     }
  6658.  
  6659.     if (fread( lpData, 1, flen, file ) != flen)
  6660.     {
  6661.         printf("READ ERROR!\n");
  6662.         return;
  6663.     }
  6664.     // This is why I added the new argument to MDxPad
  6665.     // So we can pass the length of the data AND the
  6666.     // Total length of the message
  6667.     // Also it now returns the # of padding bytes added,
  6668.     // this is for files that are an exact multiple of the chunk
  6669.     // length. (Otherwise the padding isn't Translated)
  6670.     flen += MDxPad( lpData, flen, mlen );
  6671.     MD5Translate( lpData, flen, &mdDataSum );    
  6672.     MD4Translate( lpData, flen, &md4DataSum );
  6673.  
  6674.     // New step necessary because of the 'chunking' method
  6675.     MDxFinalize( &mdDataSum );
  6676.     MDxFinalize( &md4DataSum );
  6677.     
  6678.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6679.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6680.     fclose(file);
  6681.         
  6682. }
  6683.  
  6684. void DigestString()
  6685. {
  6686.     
  6687.     //For our demo purposes, no strings bigger than 1024 :)
  6688.     unsigned char lpData[1024] = "";
  6689.     long len = 0;
  6690.     MDxSum mdDataSum;
  6691.  
  6692.     printf("Enter the string to digest: ");
  6693.     scanf("%s", &lpData );
  6694.     len = strlen(lpData);
  6695.     
  6696.     // Have to do this before the Padding...well...it's best anyway;)
  6697.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  6698.     
  6699.     // For the strings, we're gonna pad and digest the string
  6700.     // in one pass.
  6701.     MDxInit( &mdDataSum );
  6702.     MDxPad( lpData, len, len );
  6703.     
  6704.     MD5Translate( lpData, len, &mdDataSum );
  6705.         // New step necessary because of the 'chunking' method
  6706.         MDxFinalize( &mdDataSum );
  6707.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6708.     
  6709.     MDxInit( &mdDataSum );
  6710.     MD4Translate( lpData, len, &mdDataSum );    
  6711.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6712.  
  6713.     return;
  6714. }
  6715.  
  6716.  
  6717. -------------- Include
  6718.  
  6719. #ifndef __windows_h__
  6720.         typedef unsigned long DWORD;
  6721.         #define STDCALL _stdcall
  6722. #endif
  6723.  
  6724. typedef struct 
  6725. {
  6726.     DWORD dwSum[4];
  6727. }MDxSum;
  6728.  
  6729. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  6730. void STDCALL MDxInit( MDxSum * );
  6731. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  6732. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  6733. const char * STDCALL MDxGetVersion();
  6734. void STDCALL MDxFinalize( MDxSum * );
  6735.  
  6736.  
  6737.  
  6738.  
  6739. #include "mdx.h"
  6740. #include <stdlib.h>
  6741. #include <stdio.h>
  6742. #include <string.h>
  6743.  
  6744. // READLEN % 64 must = 0
  6745. #define READLEN    1048576L // 2^20, 1MB
  6746.  
  6747. void DigestFile( char * );
  6748. void DigestString();
  6749.  
  6750. void main(int argc, char *argv[])
  6751. {
  6752.     printf("%s\n\n", MDxGetVersion());
  6753.  
  6754.     if( argc > 1 )
  6755.         DigestFile( argv[1] );
  6756.     else    
  6757.         DigestString();
  6758.  
  6759. }
  6760.  
  6761. /*
  6762.     I use the 'chunk' method for processing files not because of
  6763.     limitations of my dll, but think what would happen if you
  6764.     tried to load an entire cd image into memory.
  6765. */
  6766. void DigestFile( char *szFName )
  6767. {
  6768.     FILE *file;
  6769.     void *lpData;
  6770.     long flen, mlen;
  6771.     MDxSum mdDataSum;
  6772.     MDxSum md4DataSum;
  6773.  
  6774.     // the 64 is for padding purposes
  6775.     lpData = malloc( READLEN + 64 );
  6776.     
  6777.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6778.  
  6779.     file = fopen( szFName, "rb" );
  6780.     if( file == NULL )
  6781.     {
  6782.         printf("ERROR: File not found.\n");
  6783.         return;
  6784.     }
  6785.     
  6786.     MDxInit( &mdDataSum );
  6787.     MDxInit( &md4DataSum );
  6788.     
  6789.     fseek( file, 0, SEEK_END );
  6790.     //Get the file length
  6791.     flen = mlen = ftell( file );
  6792.     fseek( file, 0, SEEK_SET );
  6793.     
  6794.     // When it takes a while to process a large file,
  6795.     // remember that for each chunk it has to run 
  6796.     // through the main translation loop 16384 times!
  6797.         
  6798.     printf("Processing %ld byte file: .", flen );
  6799.     
  6800.     while( flen > READLEN )
  6801.     {
  6802.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6803.         {
  6804.             printf("READ ERROR!\n");
  6805.             return;
  6806.         }
  6807.         MD5Translate( lpData, READLEN, &mdDataSum );
  6808.         MD4Translate( lpData, READLEN, &md4DataSum );
  6809.         flen -= READLEN;
  6810.         printf(".");
  6811.     }
  6812.  
  6813.     if (fread( lpData, 1, flen, file ) != flen)
  6814.     {
  6815.         printf("READ ERROR!\n");
  6816.         return;
  6817.     }
  6818.     // This is why I added the new argument to MDxPad
  6819.     // So we can pass the length of the data AND the
  6820.     // Total length of the message
  6821.     // Also it now returns the # of padding bytes added,
  6822.     // this is for files that are an exact multiple of the chunk
  6823.     // length. (Otherwise the padding isn't Translated)
  6824.     flen += MDxPad( lpData, flen, mlen );
  6825.     MD5Translate( lpData, flen, &mdDataSum );    
  6826.     MD4Translate( lpData, flen, &md4DataSum );
  6827.  
  6828.     // New step necessary because of the 'chunking' method
  6829.     MDxFinalize( &mdDataSum );
  6830.     MDxFinalize( &md4DataSum );
  6831.     
  6832.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6833.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6834.     fclose(file);
  6835.         
  6836. }
  6837.  
  6838. void DigestString()
  6839. {
  6840.     
  6841.     //For our demo purposes, no strings bigger than 1024 :)
  6842.     unsigned char lpData[1024] = "";
  6843.     long len = 0;
  6844.     MDxSum mdDataSum;
  6845.  
  6846.     printf("Enter the string to digest: ");
  6847.     scanf("%s", &lpData );
  6848.     len = strlen(lpData);
  6849.     
  6850.     // Have to do this before the Padding...well...it's best anyway;)
  6851.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  6852.     
  6853.     // For the strings, we're gonna pad and digest the string
  6854.     // in one pass.
  6855.     MDxInit( &mdDataSum );
  6856.     MDxPad( lpData, len, len );
  6857.     
  6858.     MD5Translate( lpData, len, &mdDataSum );
  6859.         // New step necessary because of the 'chunking' method
  6860.         MDxFinalize( &mdDataSum );
  6861.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6862.     
  6863.     MDxInit( &mdDataSum );
  6864.     MD4Translate( lpData, len, &mdDataSum );    
  6865.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6866.  
  6867.     return;
  6868. }
  6869.  
  6870.  
  6871. -------------- Include
  6872.  
  6873. #ifndef __windows_h__
  6874.         typedef unsigned long DWORD;
  6875.         #define STDCALL _stdcall
  6876. #endif
  6877.  
  6878. typedef struct 
  6879. {
  6880.     DWORD dwSum[4];
  6881. }MDxSum;
  6882.  
  6883. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  6884. void STDCALL MDxInit( MDxSum * );
  6885. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  6886. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  6887. const char * STDCALL MDxGetVersion();
  6888. void STDCALL MDxFinalize( MDxSum * );
  6889.  
  6890.  
  6891.  
  6892.  
  6893. #include "mdx.h"
  6894. #include <stdlib.h>
  6895. #include <stdio.h>
  6896. #include <string.h>
  6897.  
  6898. // READLEN % 64 must = 0
  6899. #define READLEN    1048576L // 2^20, 1MB
  6900.  
  6901. void DigestFile( char * );
  6902. void DigestString();
  6903.  
  6904. void main(int argc, char *argv[])
  6905. {
  6906.     printf("%s\n\n", MDxGetVersion());
  6907.  
  6908.     if( argc > 1 )
  6909.         DigestFile( argv[1] );
  6910.     else    
  6911.         DigestString();
  6912.  
  6913. }
  6914.  
  6915. /*
  6916.     I use the 'chunk' method for processing files not because of
  6917.     limitations of my dll, but think what would happen if you
  6918.     tried to load an entire cd image into memory.
  6919. */
  6920. void DigestFile( char *szFName )
  6921. {
  6922.     FILE *file;
  6923.     void *lpData;
  6924.     long flen, mlen;
  6925.     MDxSum mdDataSum;
  6926.     MDxSum md4DataSum;
  6927.  
  6928.     // the 64 is for padding purposes
  6929.     lpData = malloc( READLEN + 64 );
  6930.     
  6931.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  6932.  
  6933.     file = fopen( szFName, "rb" );
  6934.     if( file == NULL )
  6935.     {
  6936.         printf("ERROR: File not found.\n");
  6937.         return;
  6938.     }
  6939.     
  6940.     MDxInit( &mdDataSum );
  6941.     MDxInit( &md4DataSum );
  6942.     
  6943.     fseek( file, 0, SEEK_END );
  6944.     //Get the file length
  6945.     flen = mlen = ftell( file );
  6946.     fseek( file, 0, SEEK_SET );
  6947.     
  6948.     // When it takes a while to process a large file,
  6949.     // remember that for each chunk it has to run 
  6950.     // through the main translation loop 16384 times!
  6951.         
  6952.     printf("Processing %ld byte file: .", flen );
  6953.     
  6954.     while( flen > READLEN )
  6955.     {
  6956.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  6957.         {
  6958.             printf("READ ERROR!\n");
  6959.             return;
  6960.         }
  6961.         MD5Translate( lpData, READLEN, &mdDataSum );
  6962.         MD4Translate( lpData, READLEN, &md4DataSum );
  6963.         flen -= READLEN;
  6964.         printf(".");
  6965.     }
  6966.  
  6967.     if (fread( lpData, 1, flen, file ) != flen)
  6968.     {
  6969.         printf("READ ERROR!\n");
  6970.         return;
  6971.     }
  6972.     // This is why I added the new argument to MDxPad
  6973.     // So we can pass the length of the data AND the
  6974.     // Total length of the message
  6975.     // Also it now returns the # of padding bytes added,
  6976.     // this is for files that are an exact multiple of the chunk
  6977.     // length. (Otherwise the padding isn't Translated)
  6978.     flen += MDxPad( lpData, flen, mlen );
  6979.     MD5Translate( lpData, flen, &mdDataSum );    
  6980.     MD4Translate( lpData, flen, &md4DataSum );
  6981.  
  6982.     // New step necessary because of the 'chunking' method
  6983.     MDxFinalize( &mdDataSum );
  6984.     MDxFinalize( &md4DataSum );
  6985.     
  6986.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  6987.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  6988.     fclose(file);
  6989.         
  6990. }
  6991.  
  6992. void DigestString()
  6993. {
  6994.     
  6995.     //For our demo purposes, no strings bigger than 1024 :)
  6996.     unsigned char lpData[1024] = "";
  6997.     long len = 0;
  6998.     MDxSum mdDataSum;
  6999.  
  7000.     printf("Enter the string to digest: ");
  7001.     scanf("%s", &lpData );
  7002.     len = strlen(lpData);
  7003.     
  7004.     // Have to do this before the Padding...well...it's best anyway;)
  7005.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7006.     
  7007.     // For the strings, we're gonna pad and digest the string
  7008.     // in one pass.
  7009.     MDxInit( &mdDataSum );
  7010.     MDxPad( lpData, len, len );
  7011.     
  7012.     MD5Translate( lpData, len, &mdDataSum );
  7013.         // New step necessary because of the 'chunking' method
  7014.         MDxFinalize( &mdDataSum );
  7015.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7016.     
  7017.     MDxInit( &mdDataSum );
  7018.     MD4Translate( lpData, len, &mdDataSum );    
  7019.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7020.  
  7021.     return;
  7022. }
  7023.  
  7024.  
  7025. -------------- Include
  7026.  
  7027. #ifndef __windows_h__
  7028.         typedef unsigned long DWORD;
  7029.         #define STDCALL _stdcall
  7030. #endif
  7031.  
  7032. typedef struct 
  7033. {
  7034.     DWORD dwSum[4];
  7035. }MDxSum;
  7036.  
  7037. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7038. void STDCALL MDxInit( MDxSum * );
  7039. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7040. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7041. const char * STDCALL MDxGetVersion();
  7042. void STDCALL MDxFinalize( MDxSum * );
  7043.  
  7044.  
  7045.  
  7046.  
  7047. #include "mdx.h"
  7048. #include <stdlib.h>
  7049. #include <stdio.h>
  7050. #include <string.h>
  7051.  
  7052. // READLEN % 64 must = 0
  7053. #define READLEN    1048576L // 2^20, 1MB
  7054.  
  7055. void DigestFile( char * );
  7056. void DigestString();
  7057.  
  7058. void main(int argc, char *argv[])
  7059. {
  7060.     printf("%s\n\n", MDxGetVersion());
  7061.  
  7062.     if( argc > 1 )
  7063.         DigestFile( argv[1] );
  7064.     else    
  7065.         DigestString();
  7066.  
  7067. }
  7068.  
  7069. /*
  7070.     I use the 'chunk' method for processing files not because of
  7071.     limitations of my dll, but think what would happen if you
  7072.     tried to load an entire cd image into memory.
  7073. */
  7074. void DigestFile( char *szFName )
  7075. {
  7076.     FILE *file;
  7077.     void *lpData;
  7078.     long flen, mlen;
  7079.     MDxSum mdDataSum;
  7080.     MDxSum md4DataSum;
  7081.  
  7082.     // the 64 is for padding purposes
  7083.     lpData = malloc( READLEN + 64 );
  7084.     
  7085.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  7086.  
  7087.     file = fopen( szFName, "rb" );
  7088.     if( file == NULL )
  7089.     {
  7090.         printf("ERROR: File not found.\n");
  7091.         return;
  7092.     }
  7093.     
  7094.     MDxInit( &mdDataSum );
  7095.     MDxInit( &md4DataSum );
  7096.     
  7097.     fseek( file, 0, SEEK_END );
  7098.     //Get the file length
  7099.     flen = mlen = ftell( file );
  7100.     fseek( file, 0, SEEK_SET );
  7101.     
  7102.     // When it takes a while to process a large file,
  7103.     // remember that for each chunk it has to run 
  7104.     // through the main translation loop 16384 times!
  7105.         
  7106.     printf("Processing %ld byte file: .", flen );
  7107.     
  7108.     while( flen > READLEN )
  7109.     {
  7110.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  7111.         {
  7112.             printf("READ ERROR!\n");
  7113.             return;
  7114.         }
  7115.         MD5Translate( lpData, READLEN, &mdDataSum );
  7116.         MD4Translate( lpData, READLEN, &md4DataSum );
  7117.         flen -= READLEN;
  7118.         printf(".");
  7119.     }
  7120.  
  7121.     if (fread( lpData, 1, flen, file ) != flen)
  7122.     {
  7123.         printf("READ ERROR!\n");
  7124.         return;
  7125.     }
  7126.     // This is why I added the new argument to MDxPad
  7127.     // So we can pass the length of the data AND the
  7128.     // Total length of the message
  7129.     // Also it now returns the # of padding bytes added,
  7130.     // this is for files that are an exact multiple of the chunk
  7131.     // length. (Otherwise the padding isn't Translated)
  7132.     flen += MDxPad( lpData, flen, mlen );
  7133.     MD5Translate( lpData, flen, &mdDataSum );    
  7134.     MD4Translate( lpData, flen, &md4DataSum );
  7135.  
  7136.     // New step necessary because of the 'chunking' method
  7137.     MDxFinalize( &mdDataSum );
  7138.     MDxFinalize( &md4DataSum );
  7139.     
  7140.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  7141.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7142.     fclose(file);
  7143.         
  7144. }
  7145.  
  7146. void DigestString()
  7147. {
  7148.     
  7149.     //For our demo purposes, no strings bigger than 1024 :)
  7150.     unsigned char lpData[1024] = "";
  7151.     long len = 0;
  7152.     MDxSum mdDataSum;
  7153.  
  7154.     printf("Enter the string to digest: ");
  7155.     scanf("%s", &lpData );
  7156.     len = strlen(lpData);
  7157.     
  7158.     // Have to do this before the Padding...well...it's best anyway;)
  7159.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7160.     
  7161.     // For the strings, we're gonna pad and digest the string
  7162.     // in one pass.
  7163.     MDxInit( &mdDataSum );
  7164.     MDxPad( lpData, len, len );
  7165.     
  7166.     MD5Translate( lpData, len, &mdDataSum );
  7167.         // New step necessary because of the 'chunking' method
  7168.         MDxFinalize( &mdDataSum );
  7169.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7170.     
  7171.     MDxInit( &mdDataSum );
  7172.     MD4Translate( lpData, len, &mdDataSum );    
  7173.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7174.  
  7175.     return;
  7176. }
  7177.  
  7178.  
  7179. -------------- Include
  7180.  
  7181. #ifndef __windows_h__
  7182.         typedef unsigned long DWORD;
  7183.         #define STDCALL _stdcall
  7184. #endif
  7185.  
  7186. typedef struct 
  7187. {
  7188.     DWORD dwSum[4];
  7189. }MDxSum;
  7190.  
  7191. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7192. void STDCALL MDxInit( MDxSum * );
  7193. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7194. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7195. const char * STDCALL MDxGetVersion();
  7196. void STDCALL MDxFinalize( MDxSum * );
  7197.  
  7198.  
  7199.  
  7200. #include "mdx.h"
  7201. #include <stdlib.h>
  7202. #include <stdio.h>
  7203. #include <string.h>
  7204.  
  7205. // READLEN % 64 must = 0
  7206. #define READLEN    1048576L // 2^20, 1MB
  7207.  
  7208. void DigestFile( char * );
  7209. void DigestString();
  7210.  
  7211. void main(int argc, char *argv[])
  7212. {
  7213.     printf("%s\n\n", MDxGetVersion());
  7214.  
  7215.     if( argc > 1 )
  7216.         DigestFile( argv[1] );
  7217.     else    
  7218.         DigestString();
  7219.  
  7220. }
  7221.  
  7222. /*
  7223.     I use the 'chunk' method for processing files not because of
  7224.     limitations of my dll, but think what would happen if you
  7225.     tried to load an entire cd image into memory.
  7226. */
  7227. void DigestFile( char *szFName )
  7228. {
  7229.     FILE *file;
  7230.     void *lpData;
  7231.     long flen, mlen;
  7232.     MDxSum mdDataSum;
  7233.     MDxSum md4DataSum;
  7234.  
  7235.     // the 64 is for padding purposes
  7236.     lpData = malloc( READLEN + 64 );
  7237.     
  7238.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  7239.  
  7240.     file = fopen( szFName, "rb" );
  7241.     if( file == NULL )
  7242.     {
  7243.         printf("ERROR: File not found.\n");
  7244.         return;
  7245.     }
  7246.     
  7247.     MDxInit( &mdDataSum );
  7248.     MDxInit( &md4DataSum );
  7249.     
  7250.     fseek( file, 0, SEEK_END );
  7251.     //Get the file length
  7252.     flen = mlen = ftell( file );
  7253.     fseek( file, 0, SEEK_SET );
  7254.     
  7255.     // When it takes a while to process a large file,
  7256.     // remember that for each chunk it has to run 
  7257.     // through the main translation loop 16384 times!
  7258.         
  7259.     printf("Processing %ld byte file: .", flen );
  7260.     
  7261.     while( flen > READLEN )
  7262.     {
  7263.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  7264.         {
  7265.             printf("READ ERROR!\n");
  7266.             return;
  7267.         }
  7268.         MD5Translate( lpData, READLEN, &mdDataSum );
  7269.         MD4Translate( lpData, READLEN, &md4DataSum );
  7270.         flen -= READLEN;
  7271.         printf(".");
  7272.     }
  7273.  
  7274.     if (fread( lpData, 1, flen, file ) != flen)
  7275.     {
  7276.         printf("READ ERROR!\n");
  7277.         return;
  7278.     }
  7279.     // This is why I added the new argument to MDxPad
  7280.     // So we can pass the length of the data AND the
  7281.     // Total length of the message
  7282.     // Also it now returns the # of padding bytes added,
  7283.     // this is for files that are an exact multiple of the chunk
  7284.     // length. (Otherwise the padding isn't Translated)
  7285.     flen += MDxPad( lpData, flen, mlen );
  7286.     MD5Translate( lpData, flen, &mdDataSum );    
  7287.     MD4Translate( lpData, flen, &md4DataSum );
  7288.  
  7289.     // New step necessary because of the 'chunking' method
  7290.     MDxFinalize( &mdDataSum );
  7291.     MDxFinalize( &md4DataSum );
  7292.     
  7293.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  7294.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7295.     fclose(file);
  7296.         
  7297. }
  7298.  
  7299. void DigestString()
  7300. {
  7301.     
  7302.     //For our demo purposes, no strings bigger than 1024 :)
  7303.     unsigned char lpData[1024] = "";
  7304.     long len = 0;
  7305.     MDxSum mdDataSum;
  7306.  
  7307.     printf("Enter the string to digest: ");
  7308.     scanf("%s", &lpData );
  7309.     len = strlen(lpData);
  7310.     
  7311.     // Have to do this before the Padding...well...it's best anyway;)
  7312.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7313.     
  7314.     // For the strings, we're gonna pad and digest the string
  7315.     // in one pass.
  7316.     MDxInit( &mdDataSum );
  7317.     MDxPad( lpData, len, len );
  7318.     
  7319.     MD5Translate( lpData, len, &mdDataSum );
  7320.         // New step necessary because of the 'chunking' method
  7321.         MDxFinalize( &mdDataSum );
  7322.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7323.     
  7324.     MDxInit( &mdDataSum );
  7325.     MD4Translate( lpData, len, &mdDataSum );    
  7326.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7327.  
  7328.     return;
  7329. }
  7330.  
  7331.  
  7332. -------------- Include
  7333.  
  7334. #ifndef __windows_h__
  7335.         typedef unsigned long DWORD;
  7336.         #define STDCALL _stdcall
  7337. #endif
  7338.  
  7339. typedef struct 
  7340. {
  7341.     DWORD dwSum[4];
  7342. }MDxSum;
  7343.  
  7344. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7345. void STDCALL MDxInit( MDxSum * );
  7346. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7347. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7348. const char * STDCALL MDxGetVersion();
  7349. void STDCALL MDxFinalize( MDxSum * );
  7350.  
  7351.  
  7352.  
  7353. #include "mdx.h"
  7354. #include <stdlib.h>
  7355. #include <stdio.h>
  7356. #include <string.h>
  7357.  
  7358. // READLEN % 64 must = 0
  7359. #define READLEN    1048576L // 2^20, 1MB
  7360.  
  7361. void DigestFile( char * );
  7362. void DigestString();
  7363.  
  7364. void main(int argc, char *argv[])
  7365. {
  7366.     printf("%s\n\n", MDxGetVersion());
  7367.  
  7368.     if( argc > 1 )
  7369.         DigestFile( argv[1] );
  7370.     else    
  7371.         DigestString();
  7372.  
  7373. }
  7374.  
  7375. /*
  7376.     I use the 'chunk' method for processing files not because of
  7377.     limitations of my dll, but think what would happen if you
  7378.     tried to load an entire cd image into memory.
  7379. */
  7380. void DigestFile( char *szFName )
  7381. {
  7382.     FILE *file;
  7383.     void *lpData;
  7384.     long flen, mlen;
  7385.     MDxSum mdDataSum;
  7386.     MDxSum md4DataSum;
  7387.  
  7388.     // the 64 is for padding purposes
  7389.     lpData = malloc( READLEN + 64 );
  7390.     
  7391.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  7392.  
  7393.     file = fopen( szFName, "rb" );
  7394.     if( file == NULL )
  7395.     {
  7396.         printf("ERROR: File not found.\n");
  7397.         return;
  7398.     }
  7399.     
  7400.     MDxInit( &mdDataSum );
  7401.     MDxInit( &md4DataSum );
  7402.     
  7403.     fseek( file, 0, SEEK_END );
  7404.     //Get the file length
  7405.     flen = mlen = ftell( file );
  7406.     fseek( file, 0, SEEK_SET );
  7407.     
  7408.     // When it takes a while to process a large file,
  7409.     // remember that for each chunk it has to run 
  7410.     // through the main translation loop 16384 times!
  7411.         
  7412.     printf("Processing %ld byte file: .", flen );
  7413.     
  7414.     while( flen > READLEN )
  7415.     {
  7416.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  7417.         {
  7418.             printf("READ ERROR!\n");
  7419.             return;
  7420.         }
  7421.         MD5Translate( lpData, READLEN, &mdDataSum );
  7422.         MD4Translate( lpData, READLEN, &md4DataSum );
  7423.         flen -= READLEN;
  7424.         printf(".");
  7425.     }
  7426.  
  7427.     if (fread( lpData, 1, flen, file ) != flen)
  7428.     {
  7429.         printf("READ ERROR!\n");
  7430.         return;
  7431.     }
  7432.     // This is why I added the new argument to MDxPad
  7433.     // So we can pass the length of the data AND the
  7434.     // Total length of the message
  7435.     // Also it now returns the # of padding bytes added,
  7436.     // this is for files that are an exact multiple of the chunk
  7437.     // length. (Otherwise the padding isn't Translated)
  7438.     flen += MDxPad( lpData, flen, mlen );
  7439.     MD5Translate( lpData, flen, &mdDataSum );    
  7440.     MD4Translate( lpData, flen, &md4DataSum );
  7441.  
  7442.     // New step necessary because of the 'chunking' method
  7443.     MDxFinalize( &mdDataSum );
  7444.     MDxFinalize( &md4DataSum );
  7445.     
  7446.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  7447.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7448.     fclose(file);
  7449.         
  7450. }
  7451.  
  7452. void DigestString()
  7453. {
  7454.     
  7455.     //For our demo purposes, no strings bigger than 1024 :)
  7456.     unsigned char lpData[1024] = "";
  7457.     long len = 0;
  7458.     MDxSum mdDataSum;
  7459.  
  7460.     printf("Enter the string to digest: ");
  7461.     scanf("%s", &lpData );
  7462.     len = strlen(lpData);
  7463.     
  7464.     // Have to do this before the Padding...well...it's best anyway;)
  7465.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7466.     
  7467.     // For the strings, we're gonna pad and digest the string
  7468.     // in one pass.
  7469.     MDxInit( &mdDataSum );
  7470.     MDxPad( lpData, len, len );
  7471.     
  7472.     MD5Translate( lpData, len, &mdDataSum );
  7473.         // New step necessary because of the 'chunking' method
  7474.         MDxFinalize( &mdDataSum );
  7475.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7476.     
  7477.     MDxInit( &mdDataSum );
  7478.     MD4Translate( lpData, len, &mdDataSum );    
  7479.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7480.  
  7481.     return;
  7482. }
  7483.  
  7484.  
  7485. -------------- Include
  7486.  
  7487. #ifndef __windows_h__
  7488.         typedef unsigned long DWORD;
  7489.         #define STDCALL _stdcall
  7490. #endif
  7491.  
  7492. typedef struct 
  7493. {
  7494.     DWORD dwSum[4];
  7495. }MDxSum;
  7496.  
  7497. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7498. void STDCALL MDxInit( MDxSum * );
  7499. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7500. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7501. const char * STDCALL MDxGetVersion();
  7502. void STDCALL MDxFinalize( MDxSum * );
  7503.  
  7504.  
  7505.  
  7506.  
  7507. #include "mdx.h"
  7508. #include <stdlib.h>
  7509. #include <stdio.h>
  7510. #include <string.h>
  7511.  
  7512. // READLEN % 64 must = 0
  7513. #define READLEN    1048576L // 2^20, 1MB
  7514.  
  7515. void DigestFile( char * );
  7516. void DigestString();
  7517.  
  7518. void main(int argc, char *argv[])
  7519. {
  7520.     printf("%s\n\n", MDxGetVersion());
  7521.  
  7522.     if( argc > 1 )
  7523.         DigestFile( argv[1] );
  7524.     else    
  7525.         DigestString();
  7526.  
  7527. }
  7528.  
  7529. /*
  7530.     I use the 'chunk' method for processing files not because of
  7531.     limitations of my dll, but think what would happen if you
  7532.     tried to load an entire cd image into memory.
  7533. */
  7534. void DigestFile( char *szFName )
  7535. {
  7536.     FILE *file;
  7537.     void *lpData;
  7538.     long flen, mlen;
  7539.     MDxSum mdDataSum;
  7540.     MDxSum md4DataSum;
  7541.  
  7542.     // the 64 is for padding purposes
  7543.     lpData = malloc( READLEN + 64 );
  7544.     
  7545.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  7546.  
  7547.     file = fopen( szFName, "rb" );
  7548.     if( file == NULL )
  7549.     {
  7550.         printf("ERROR: File not found.\n");
  7551.         return;
  7552.     }
  7553.     
  7554.     MDxInit( &mdDataSum );
  7555.     MDxInit( &md4DataSum );
  7556.     
  7557.     fseek( file, 0, SEEK_END );
  7558.     //Get the file length
  7559.     flen = mlen = ftell( file );
  7560.     fseek( file, 0, SEEK_SET );
  7561.     
  7562.     // When it takes a while to process a large file,
  7563.     // remember that for each chunk it has to run 
  7564.     // through the main translation loop 16384 times!
  7565.         
  7566.     printf("Processing %ld byte file: .", flen );
  7567.     
  7568.     while( flen > READLEN )
  7569.     {
  7570.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  7571.         {
  7572.             printf("READ ERROR!\n");
  7573.             return;
  7574.         }
  7575.         MD5Translate( lpData, READLEN, &mdDataSum );
  7576.         MD4Translate( lpData, READLEN, &md4DataSum );
  7577.         flen -= READLEN;
  7578.         printf(".");
  7579.     }
  7580.  
  7581.     if (fread( lpData, 1, flen, file ) != flen)
  7582.     {
  7583.         printf("READ ERROR!\n");
  7584.         return;
  7585.     }
  7586.     // This is why I added the new argument to MDxPad
  7587.     // So we can pass the length of the data AND the
  7588.     // Total length of the message
  7589.     // Also it now returns the # of padding bytes added,
  7590.     // this is for files that are an exact multiple of the chunk
  7591.     // length. (Otherwise the padding isn't Translated)
  7592.     flen += MDxPad( lpData, flen, mlen );
  7593.     MD5Translate( lpData, flen, &mdDataSum );    
  7594.     MD4Translate( lpData, flen, &md4DataSum );
  7595.  
  7596.     // New step necessary because of the 'chunking' method
  7597.     MDxFinalize( &mdDataSum );
  7598.     MDxFinalize( &md4DataSum );
  7599.     
  7600.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  7601.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7602.     fclose(file);
  7603.         
  7604. }
  7605.  
  7606. void DigestString()
  7607. {
  7608.     
  7609.     //For our demo purposes, no strings bigger than 1024 :)
  7610.     unsigned char lpData[1024] = "";
  7611.     long len = 0;
  7612.     MDxSum mdDataSum;
  7613.  
  7614.     printf("Enter the string to digest: ");
  7615.     scanf("%s", &lpData );
  7616.     len = strlen(lpData);
  7617.     
  7618.     // Have to do this before the Padding...well...it's best anyway;)
  7619.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7620.     
  7621.     // For the strings, we're gonna pad and digest the string
  7622.     // in one pass.
  7623.     MDxInit( &mdDataSum );
  7624.     MDxPad( lpData, len, len );
  7625.     
  7626.     MD5Translate( lpData, len, &mdDataSum );
  7627.         // New step necessary because of the 'chunking' method
  7628.         MDxFinalize( &mdDataSum );
  7629.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7630.     
  7631.     MDxInit( &mdDataSum );
  7632.     MD4Translate( lpData, len, &mdDataSum );    
  7633.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7634.  
  7635.     return;
  7636. }
  7637.  
  7638.  
  7639. -------------- Include
  7640.  
  7641. #ifndef __windows_h__
  7642.         typedef unsigned long DWORD;
  7643.         #define STDCALL _stdcall
  7644. #endif
  7645.  
  7646. typedef struct 
  7647. {
  7648.     DWORD dwSum[4];
  7649. }MDxSum;
  7650.  
  7651. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7652. void STDCALL MDxInit( MDxSum * );
  7653. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7654. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7655. const char * STDCALL MDxGetVersion();
  7656. void STDCALL MDxFinalize( MDxSum * );
  7657.  
  7658.  
  7659.  
  7660. #include "mdx.h"
  7661. #include <stdlib.h>
  7662. #include <stdio.h>
  7663. #include <string.h>
  7664.  
  7665. // READLEN % 64 must = 0
  7666. #define READLEN    1048576L // 2^20, 1MB
  7667.  
  7668. void DigestFile( char * );
  7669. void DigestString();
  7670.  
  7671. void main(int argc, char *argv[])
  7672. {
  7673.     printf("%s\n\n", MDxGetVersion());
  7674.  
  7675.     if( argc > 1 )
  7676.         DigestFile( argv[1] );
  7677.     else    
  7678.         DigestString();
  7679.  
  7680. }
  7681.  
  7682. /*
  7683.     I use the 'chunk' method for processing files not because of
  7684.     limitations of my dll, but think what would happen if you
  7685.     tried to load an entire cd image into memory.
  7686. */
  7687. void DigestFile( char *szFName )
  7688. {
  7689.     FILE *file;
  7690.     void *lpData;
  7691.     long flen, mlen;
  7692.     MDxSum mdDataSum;
  7693.     MDxSum md4DataSum;
  7694.  
  7695.     // the 64 is for padding purposes
  7696.     lpData = malloc( READLEN + 64 );
  7697.     
  7698.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  7699.  
  7700.     file = fopen( szFName, "rb" );
  7701.     if( file == NULL )
  7702.     {
  7703.         printf("ERROR: File not found.\n");
  7704.         return;
  7705.     }
  7706.     
  7707.     MDxInit( &mdDataSum );
  7708.     MDxInit( &md4DataSum );
  7709.     
  7710.     fseek( file, 0, SEEK_END );
  7711.     //Get the file length
  7712.     flen = mlen = ftell( file );
  7713.     fseek( file, 0, SEEK_SET );
  7714.     
  7715.     // When it takes a while to process a large file,
  7716.     // remember that for each chunk it has to run 
  7717.     // through the main translation loop 16384 times!
  7718.         
  7719.     printf("Processing %ld byte file: .", flen );
  7720.     
  7721.     while( flen > READLEN )
  7722.     {
  7723.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  7724.         {
  7725.             printf("READ ERROR!\n");
  7726.             return;
  7727.         }
  7728.         MD5Translate( lpData, READLEN, &mdDataSum );
  7729.         MD4Translate( lpData, READLEN, &md4DataSum );
  7730.         flen -= READLEN;
  7731.         printf(".");
  7732.     }
  7733.  
  7734.     if (fread( lpData, 1, flen, file ) != flen)
  7735.     {
  7736.         printf("READ ERROR!\n");
  7737.         return;
  7738.     }
  7739.     // This is why I added the new argument to MDxPad
  7740.     // So we can pass the length of the data AND the
  7741.     // Total length of the message
  7742.     // Also it now returns the # of padding bytes added,
  7743.     // this is for files that are an exact multiple of the chunk
  7744.     // length. (Otherwise the padding isn't Translated)
  7745.     flen += MDxPad( lpData, flen, mlen );
  7746.     MD5Translate( lpData, flen, &mdDataSum );    
  7747.     MD4Translate( lpData, flen, &md4DataSum );
  7748.  
  7749.     // New step necessary because of the 'chunking' method
  7750.     MDxFinalize( &mdDataSum );
  7751.     MDxFinalize( &md4DataSum );
  7752.     
  7753.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  7754.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7755.     fclose(file);
  7756.         
  7757. }
  7758.  
  7759. void DigestString()
  7760. {
  7761.     
  7762.     //For our demo purposes, no strings bigger than 1024 :)
  7763.     unsigned char lpData[1024] = "";
  7764.     long len = 0;
  7765.     MDxSum mdDataSum;
  7766.  
  7767.     printf("Enter the string to digest: ");
  7768.     scanf("%s", &lpData );
  7769.     len = strlen(lpData);
  7770.     
  7771.     // Have to do this before the Padding...well...it's best anyway;)
  7772.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7773.     
  7774.     // For the strings, we're gonna pad and digest the string
  7775.     // in one pass.
  7776.     MDxInit( &mdDataSum );
  7777.     MDxPad( lpData, len, len );
  7778.     
  7779.     MD5Translate( lpData, len, &mdDataSum );
  7780.         // New step necessary because of the 'chunking' method
  7781.         MDxFinalize( &mdDataSum );
  7782.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7783.     
  7784.     MDxInit( &mdDataSum );
  7785.     MD4Translate( lpData, len, &mdDataSum );    
  7786.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7787.  
  7788.     return;
  7789. }
  7790.  
  7791.  
  7792. -------------- Include
  7793.  
  7794. #ifndef __windows_h__
  7795.         typedef unsigned long DWORD;
  7796.         #define STDCALL _stdcall
  7797. #endif
  7798.  
  7799. typedef struct 
  7800. {
  7801.     DWORD dwSum[4];
  7802. }MDxSum;
  7803.  
  7804. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7805. void STDCALL MDxInit( MDxSum * );
  7806. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7807. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7808. const char * STDCALL MDxGetVersion();
  7809. void STDCALL MDxFinalize( MDxSum * );
  7810.  
  7811.  
  7812.  
  7813.  
  7814. #include "mdx.h"
  7815. #include <stdlib.h>
  7816. #include <stdio.h>
  7817. #include <string.h>
  7818.  
  7819. // READLEN % 64 must = 0
  7820. #define READLEN    1048576L // 2^20, 1MB
  7821.  
  7822. void DigestFile( char * );
  7823. void DigestString();
  7824.  
  7825. void main(int argc, char *argv[])
  7826. {
  7827.     printf("%s\n\n", MDxGetVersion());
  7828.  
  7829.     if( argc > 1 )
  7830.         DigestFile( argv[1] );
  7831.     else    
  7832.         DigestString();
  7833.  
  7834. }
  7835.  
  7836. /*
  7837.     I use the 'chunk' method for processing files not because of
  7838.     limitations of my dll, but think what would happen if you
  7839.     tried to load an entire cd image into memory.
  7840. */
  7841. void DigestFile( char *szFName )
  7842. {
  7843.     FILE *file;
  7844.     void *lpData;
  7845.     long flen, mlen;
  7846.     MDxSum mdDataSum;
  7847.     MDxSum md4DataSum;
  7848.  
  7849.     // the 64 is for padding purposes
  7850.     lpData = malloc( READLEN + 64 );
  7851.     
  7852.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  7853.  
  7854.     file = fopen( szFName, "rb" );
  7855.     if( file == NULL )
  7856.     {
  7857.         printf("ERROR: File not found.\n");
  7858.         return;
  7859.     }
  7860.     
  7861.     MDxInit( &mdDataSum );
  7862.     MDxInit( &md4DataSum );
  7863.     
  7864.     fseek( file, 0, SEEK_END );
  7865.     //Get the file length
  7866.     flen = mlen = ftell( file );
  7867.     fseek( file, 0, SEEK_SET );
  7868.     
  7869.     // When it takes a while to process a large file,
  7870.     // remember that for each chunk it has to run 
  7871.     // through the main translation loop 16384 times!
  7872.         
  7873.     printf("Processing %ld byte file: .", flen );
  7874.     
  7875.     while( flen > READLEN )
  7876.     {
  7877.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  7878.         {
  7879.             printf("READ ERROR!\n");
  7880.             return;
  7881.         }
  7882.         MD5Translate( lpData, READLEN, &mdDataSum );
  7883.         MD4Translate( lpData, READLEN, &md4DataSum );
  7884.         flen -= READLEN;
  7885.         printf(".");
  7886.     }
  7887.  
  7888.     if (fread( lpData, 1, flen, file ) != flen)
  7889.     {
  7890.         printf("READ ERROR!\n");
  7891.         return;
  7892.     }
  7893.     // This is why I added the new argument to MDxPad
  7894.     // So we can pass the length of the data AND the
  7895.     // Total length of the message
  7896.     // Also it now returns the # of padding bytes added,
  7897.     // this is for files that are an exact multiple of the chunk
  7898.     // length. (Otherwise the padding isn't Translated)
  7899.     flen += MDxPad( lpData, flen, mlen );
  7900.     MD5Translate( lpData, flen, &mdDataSum );    
  7901.     MD4Translate( lpData, flen, &md4DataSum );
  7902.  
  7903.     // New step necessary because of the 'chunking' method
  7904.     MDxFinalize( &mdDataSum );
  7905.     MDxFinalize( &md4DataSum );
  7906.     
  7907.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  7908.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7909.     fclose(file);
  7910.         
  7911. }
  7912.  
  7913. void DigestString()
  7914. {
  7915.     
  7916.     //For our demo purposes, no strings bigger than 1024 :)
  7917.     unsigned char lpData[1024] = "";
  7918.     long len = 0;
  7919.     MDxSum mdDataSum;
  7920.  
  7921.     printf("Enter the string to digest: ");
  7922.     scanf("%s", &lpData );
  7923.     len = strlen(lpData);
  7924.     
  7925.     // Have to do this before the Padding...well...it's best anyway;)
  7926.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  7927.     
  7928.     // For the strings, we're gonna pad and digest the string
  7929.     // in one pass.
  7930.     MDxInit( &mdDataSum );
  7931.     MDxPad( lpData, len, len );
  7932.     
  7933.     MD5Translate( lpData, len, &mdDataSum );
  7934.         // New step necessary because of the 'chunking' method
  7935.         MDxFinalize( &mdDataSum );
  7936.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7937.     
  7938.     MDxInit( &mdDataSum );
  7939.     MD4Translate( lpData, len, &mdDataSum );    
  7940.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  7941.  
  7942.     return;
  7943. }
  7944.  
  7945.  
  7946. -------------- Include
  7947.  
  7948. #ifndef __windows_h__
  7949.         typedef unsigned long DWORD;
  7950.         #define STDCALL _stdcall
  7951. #endif
  7952.  
  7953. typedef struct 
  7954. {
  7955.     DWORD dwSum[4];
  7956. }MDxSum;
  7957.  
  7958. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  7959. void STDCALL MDxInit( MDxSum * );
  7960. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  7961. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  7962. const char * STDCALL MDxGetVersion();
  7963. void STDCALL MDxFinalize( MDxSum * );
  7964.  
  7965.  
  7966.  
  7967.  
  7968. #include "mdx.h"
  7969. #include <stdlib.h>
  7970. #include <stdio.h>
  7971. #include <string.h>
  7972.  
  7973. // READLEN % 64 must = 0
  7974. #define READLEN    1048576L // 2^20, 1MB
  7975.  
  7976. void DigestFile( char * );
  7977. void DigestString();
  7978.  
  7979. void main(int argc, char *argv[])
  7980. {
  7981.     printf("%s\n\n", MDxGetVersion());
  7982.  
  7983.     if( argc > 1 )
  7984.         DigestFile( argv[1] );
  7985.     else    
  7986.         DigestString();
  7987.  
  7988. }
  7989.  
  7990. /*
  7991.     I use the 'chunk' method for processing files not because of
  7992.     limitations of my dll, but think what would happen if you
  7993.     tried to load an entire cd image into memory.
  7994. */
  7995. void DigestFile( char *szFName )
  7996. {
  7997.     FILE *file;
  7998.     void *lpData;
  7999.     long flen, mlen;
  8000.     MDxSum mdDataSum;
  8001.     MDxSum md4DataSum;
  8002.  
  8003.     // the 64 is for padding purposes
  8004.     lpData = malloc( READLEN + 64 );
  8005.     
  8006.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8007.  
  8008.     file = fopen( szFName, "rb" );
  8009.     if( file == NULL )
  8010.     {
  8011.         printf("ERROR: File not found.\n");
  8012.         return;
  8013.     }
  8014.     
  8015.     MDxInit( &mdDataSum );
  8016.     MDxInit( &md4DataSum );
  8017.     
  8018.     fseek( file, 0, SEEK_END );
  8019.     //Get the file length
  8020.     flen = mlen = ftell( file );
  8021.     fseek( file, 0, SEEK_SET );
  8022.     
  8023.     // When it takes a while to process a large file,
  8024.     // remember that for each chunk it has to run 
  8025.     // through the main translation loop 16384 times!
  8026.         
  8027.     printf("Processing %ld byte file: .", flen );
  8028.     
  8029.     while( flen > READLEN )
  8030.     {
  8031.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8032.         {
  8033.             printf("READ ERROR!\n");
  8034.             return;
  8035.         }
  8036.         MD5Translate( lpData, READLEN, &mdDataSum );
  8037.         MD4Translate( lpData, READLEN, &md4DataSum );
  8038.         flen -= READLEN;
  8039.         printf(".");
  8040.     }
  8041.  
  8042.     if (fread( lpData, 1, flen, file ) != flen)
  8043.     {
  8044.         printf("READ ERROR!\n");
  8045.         return;
  8046.     }
  8047.     // This is why I added the new argument to MDxPad
  8048.     // So we can pass the length of the data AND the
  8049.     // Total length of the message
  8050.     // Also it now returns the # of padding bytes added,
  8051.     // this is for files that are an exact multiple of the chunk
  8052.     // length. (Otherwise the padding isn't Translated)
  8053.     flen += MDxPad( lpData, flen, mlen );
  8054.     MD5Translate( lpData, flen, &mdDataSum );    
  8055.     MD4Translate( lpData, flen, &md4DataSum );
  8056.  
  8057.     // New step necessary because of the 'chunking' method
  8058.     MDxFinalize( &mdDataSum );
  8059.     MDxFinalize( &md4DataSum );
  8060.     
  8061.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8062.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8063.     fclose(file);
  8064.         
  8065. }
  8066.  
  8067. void DigestString()
  8068. {
  8069.     
  8070.     //For our demo purposes, no strings bigger than 1024 :)
  8071.     unsigned char lpData[1024] = "";
  8072.     long len = 0;
  8073.     MDxSum mdDataSum;
  8074.  
  8075.     printf("Enter the string to digest: ");
  8076.     scanf("%s", &lpData );
  8077.     len = strlen(lpData);
  8078.     
  8079.     // Have to do this before the Padding...well...it's best anyway;)
  8080.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8081.     
  8082.     // For the strings, we're gonna pad and digest the string
  8083.     // in one pass.
  8084.     MDxInit( &mdDataSum );
  8085.     MDxPad( lpData, len, len );
  8086.     
  8087.     MD5Translate( lpData, len, &mdDataSum );
  8088.         // New step necessary because of the 'chunking' method
  8089.         MDxFinalize( &mdDataSum );
  8090.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8091.     
  8092.     MDxInit( &mdDataSum );
  8093.     MD4Translate( lpData, len, &mdDataSum );    
  8094.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8095.  
  8096.     return;
  8097. }
  8098.  
  8099.  
  8100. -------------- Include
  8101.  
  8102. #ifndef __windows_h__
  8103.         typedef unsigned long DWORD;
  8104.         #define STDCALL _stdcall
  8105. #endif
  8106.  
  8107. typedef struct 
  8108. {
  8109.     DWORD dwSum[4];
  8110. }MDxSum;
  8111.  
  8112. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  8113. void STDCALL MDxInit( MDxSum * );
  8114. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  8115. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  8116. const char * STDCALL MDxGetVersion();
  8117. void STDCALL MDxFinalize( MDxSum * );
  8118.  
  8119.  
  8120.  
  8121. #include "mdx.h"
  8122. #include <stdlib.h>
  8123. #include <stdio.h>
  8124. #include <string.h>
  8125.  
  8126. // READLEN % 64 must = 0
  8127. #define READLEN    1048576L // 2^20, 1MB
  8128.  
  8129. void DigestFile( char * );
  8130. void DigestString();
  8131.  
  8132. void main(int argc, char *argv[])
  8133. {
  8134.     printf("%s\n\n", MDxGetVersion());
  8135.  
  8136.     if( argc > 1 )
  8137.         DigestFile( argv[1] );
  8138.     else    
  8139.         DigestString();
  8140.  
  8141. }
  8142.  
  8143. /*
  8144.     I use the 'chunk' method for processing files not because of
  8145.     limitations of my dll, but think what would happen if you
  8146.     tried to load an entire cd image into memory.
  8147. */
  8148. void DigestFile( char *szFName )
  8149. {
  8150.     FILE *file;
  8151.     void *lpData;
  8152.     long flen, mlen;
  8153.     MDxSum mdDataSum;
  8154.     MDxSum md4DataSum;
  8155.  
  8156.     // the 64 is for padding purposes
  8157.     lpData = malloc( READLEN + 64 );
  8158.     
  8159.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8160.  
  8161.     file = fopen( szFName, "rb" );
  8162.     if( file == NULL )
  8163.     {
  8164.         printf("ERROR: File not found.\n");
  8165.         return;
  8166.     }
  8167.     
  8168.     MDxInit( &mdDataSum );
  8169.     MDxInit( &md4DataSum );
  8170.     
  8171.     fseek( file, 0, SEEK_END );
  8172.     //Get the file length
  8173.     flen = mlen = ftell( file );
  8174.     fseek( file, 0, SEEK_SET );
  8175.     
  8176.     // When it takes a while to process a large file,
  8177.     // remember that for each chunk it has to run 
  8178.     // through the main translation loop 16384 times!
  8179.         
  8180.     printf("Processing %ld byte file: .", flen );
  8181.     
  8182.     while( flen > READLEN )
  8183.     {
  8184.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8185.         {
  8186.             printf("READ ERROR!\n");
  8187.             return;
  8188.         }
  8189.         MD5Translate( lpData, READLEN, &mdDataSum );
  8190.         MD4Translate( lpData, READLEN, &md4DataSum );
  8191.         flen -= READLEN;
  8192.         printf(".");
  8193.     }
  8194.  
  8195.     if (fread( lpData, 1, flen, file ) != flen)
  8196.     {
  8197.         printf("READ ERROR!\n");
  8198.         return;
  8199.     }
  8200.     // This is why I added the new argument to MDxPad
  8201.     // So we can pass the length of the data AND the
  8202.     // Total length of the message
  8203.     // Also it now returns the # of padding bytes added,
  8204.     // this is for files that are an exact multiple of the chunk
  8205.     // length. (Otherwise the padding isn't Translated)
  8206.     flen += MDxPad( lpData, flen, mlen );
  8207.     MD5Translate( lpData, flen, &mdDataSum );    
  8208.     MD4Translate( lpData, flen, &md4DataSum );
  8209.  
  8210.     // New step necessary because of the 'chunking' method
  8211.     MDxFinalize( &mdDataSum );
  8212.     MDxFinalize( &md4DataSum );
  8213.     
  8214.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8215.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8216.     fclose(file);
  8217.         
  8218. }
  8219.  
  8220. void DigestString()
  8221. {
  8222.     
  8223.     //For our demo purposes, no strings bigger than 1024 :)
  8224.     unsigned char lpData[1024] = "";
  8225.     long len = 0;
  8226.     MDxSum mdDataSum;
  8227.  
  8228.     printf("Enter the string to digest: ");
  8229.     scanf("%s", &lpData );
  8230.     len = strlen(lpData);
  8231.     
  8232.     // Have to do this before the Padding...well...it's best anyway;)
  8233.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8234.     
  8235.     // For the strings, we're gonna pad and digest the string
  8236.     // in one pass.
  8237.     MDxInit( &mdDataSum );
  8238.     MDxPad( lpData, len, len );
  8239.     
  8240.     MD5Translate( lpData, len, &mdDataSum );
  8241.         // New step necessary because of the 'chunking' method
  8242.         MDxFinalize( &mdDataSum );
  8243.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8244.     
  8245.     MDxInit( &mdDataSum );
  8246.     MD4Translate( lpData, len, &mdDataSum );    
  8247.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8248.  
  8249.     return;
  8250. }
  8251.  
  8252.  
  8253. -------------- Include
  8254.  
  8255. #ifndef __windows_h__
  8256.         typedef unsigned long DWORD;
  8257.         #define STDCALL _stdcall
  8258. #endif
  8259.  
  8260. typedef struct 
  8261. {
  8262.     DWORD dwSum[4];
  8263. }MDxSum;
  8264.  
  8265. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  8266. void STDCALL MDxInit( MDxSum * );
  8267. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  8268. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  8269. const char * STDCALL MDxGetVersion();
  8270. void STDCALL MDxFinalize( MDxSum * );
  8271.  
  8272.  
  8273. #include "mdx.h"
  8274. #include <stdlib.h>
  8275. #include <stdio.h>
  8276. #include <string.h>
  8277.  
  8278. // READLEN % 64 must = 0
  8279. #define READLEN    1048576L // 2^20, 1MB
  8280.  
  8281. void DigestFile( char * );
  8282. void DigestString();
  8283.  
  8284. void main(int argc, char *argv[])
  8285. {
  8286.     printf("%s\n\n", MDxGetVersion());
  8287.  
  8288.     if( argc > 1 )
  8289.         DigestFile( argv[1] );
  8290.     else    
  8291.         DigestString();
  8292.  
  8293. }
  8294.  
  8295. /*
  8296.     I use the 'chunk' method for processing files not because of
  8297.     limitations of my dll, but think what would happen if you
  8298.     tried to load an entire cd image into memory.
  8299. */
  8300. void DigestFile( char *szFName )
  8301. {
  8302.     FILE *file;
  8303.     void *lpData;
  8304.     long flen, mlen;
  8305.     MDxSum mdDataSum;
  8306.     MDxSum md4DataSum;
  8307.  
  8308.     // the 64 is for padding purposes
  8309.     lpData = malloc( READLEN + 64 );
  8310.     
  8311.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8312.  
  8313.     file = fopen( szFName, "rb" );
  8314.     if( file == NULL )
  8315.     {
  8316.         printf("ERROR: File not found.\n");
  8317.         return;
  8318.     }
  8319.     
  8320.     MDxInit( &mdDataSum );
  8321.     MDxInit( &md4DataSum );
  8322.     
  8323.     fseek( file, 0, SEEK_END );
  8324.     //Get the file length
  8325.     flen = mlen = ftell( file );
  8326.     fseek( file, 0, SEEK_SET );
  8327.     
  8328.     // When it takes a while to process a large file,
  8329.     // remember that for each chunk it has to run 
  8330.     // through the main translation loop 16384 times!
  8331.         
  8332.     printf("Processing %ld byte file: .", flen );
  8333.     
  8334.     while( flen > READLEN )
  8335.     {
  8336.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8337.         {
  8338.             printf("READ ERROR!\n");
  8339.             return;
  8340.         }
  8341.         MD5Translate( lpData, READLEN, &mdDataSum );
  8342.         MD4Translate( lpData, READLEN, &md4DataSum );
  8343.         flen -= READLEN;
  8344.         printf(".");
  8345.     }
  8346.  
  8347.     if (fread( lpData, 1, flen, file ) != flen)
  8348.     {
  8349.         printf("READ ERROR!\n");
  8350.         return;
  8351.     }
  8352.     // This is why I added the new argument to MDxPad
  8353.     // So we can pass the length of the data AND the
  8354.     // Total length of the message
  8355.     // Also it now returns the # of padding bytes added,
  8356.     // this is for files that are an exact multiple of the chunk
  8357.     // length. (Otherwise the padding isn't Translated)
  8358.     flen += MDxPad( lpData, flen, mlen );
  8359.     MD5Translate( lpData, flen, &mdDataSum );    
  8360.     MD4Translate( lpData, flen, &md4DataSum );
  8361.  
  8362.     // New step necessary because of the 'chunking' method
  8363.     MDxFinalize( &mdDataSum );
  8364.     MDxFinalize( &md4DataSum );
  8365.     
  8366.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8367.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8368.     fclose(file);
  8369.         
  8370. }
  8371.  
  8372. void DigestString()
  8373. {
  8374.     
  8375.     //For our demo purposes, no strings bigger than 1024 :)
  8376.     unsigned char lpData[1024] = "";
  8377.     long len = 0;
  8378.     MDxSum mdDataSum;
  8379.  
  8380.     printf("Enter the string to digest: ");
  8381.     scanf("%s", &lpData );
  8382.     len = strlen(lpData);
  8383.     
  8384.     // Have to do this before the Padding...well...it's best anyway;)
  8385.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8386.     
  8387.     // For the strings, we're gonna pad and digest the string
  8388.     // in one pass.
  8389.     MDxInit( &mdDataSum );
  8390.     MDxPad( lpData, len, len );
  8391.     
  8392.     MD5Translate( lpData, len, &mdDataSum );
  8393.         // New step necessary because of the 'chunking' method
  8394.         MDxFinalize( &mdDataSum );
  8395.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8396.     
  8397.     MDxInit( &mdDataSum );
  8398.     MD4Translate( lpData, len, &mdDataSum );    
  8399.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8400.  
  8401.     return;
  8402. }
  8403.  
  8404.  
  8405. -------------- Include
  8406.  
  8407. #ifndef __windows_h__
  8408.         typedef unsigned long DWORD;
  8409.         #define STDCALL _stdcall
  8410. #endif
  8411.  
  8412. typedef struct 
  8413. {
  8414.     DWORD dwSum[4];
  8415. }MDxSum;
  8416.  
  8417. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  8418. void STDCALL MDxInit( MDxSum * );
  8419. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  8420. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  8421. const char * STDCALL MDxGetVersion();
  8422. void STDCALL MDxFinalize( MDxSum * );
  8423.  
  8424.  
  8425.  
  8426. #include "mdx.h"
  8427. #include <stdlib.h>
  8428. #include <stdio.h>
  8429. #include <string.h>
  8430.  
  8431. // READLEN % 64 must = 0
  8432. #define READLEN    1048576L // 2^20, 1MB
  8433.  
  8434. void DigestFile( char * );
  8435. void DigestString();
  8436.  
  8437. void main(int argc, char *argv[])
  8438. {
  8439.     printf("%s\n\n", MDxGetVersion());
  8440.  
  8441.     if( argc > 1 )
  8442.         DigestFile( argv[1] );
  8443.     else    
  8444.         DigestString();
  8445.  
  8446. }
  8447.  
  8448. /*
  8449.     I use the 'chunk' method for processing files not because of
  8450.     limitations of my dll, but think what would happen if you
  8451.     tried to load an entire cd image into memory.
  8452. */
  8453. void DigestFile( char *szFName )
  8454. {
  8455.     FILE *file;
  8456.     void *lpData;
  8457.     long flen, mlen;
  8458.     MDxSum mdDataSum;
  8459.     MDxSum md4DataSum;
  8460.  
  8461.     // the 64 is for padding purposes
  8462.     lpData = malloc( READLEN + 64 );
  8463.     
  8464.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8465.  
  8466.     file = fopen( szFName, "rb" );
  8467.     if( file == NULL )
  8468.     {
  8469.         printf("ERROR: File not found.\n");
  8470.         return;
  8471.     }
  8472.     
  8473.     MDxInit( &mdDataSum );
  8474.     MDxInit( &md4DataSum );
  8475.     
  8476.     fseek( file, 0, SEEK_END );
  8477.     //Get the file length
  8478.     flen = mlen = ftell( file );
  8479.     fseek( file, 0, SEEK_SET );
  8480.     
  8481.     // When it takes a while to process a large file,
  8482.     // remember that for each chunk it has to run 
  8483.     // through the main translation loop 16384 times!
  8484.         
  8485.     printf("Processing %ld byte file: .", flen );
  8486.     
  8487.     while( flen > READLEN )
  8488.     {
  8489.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8490.         {
  8491.             printf("READ ERROR!\n");
  8492.             return;
  8493.         }
  8494.         MD5Translate( lpData, READLEN, &mdDataSum );
  8495.         MD4Translate( lpData, READLEN, &md4DataSum );
  8496.         flen -= READLEN;
  8497.         printf(".");
  8498.     }
  8499.  
  8500.     if (fread( lpData, 1, flen, file ) != flen)
  8501.     {
  8502.         printf("READ ERROR!\n");
  8503.         return;
  8504.     }
  8505.     // This is why I added the new argument to MDxPad
  8506.     // So we can pass the length of the data AND the
  8507.     // Total length of the message
  8508.     // Also it now returns the # of padding bytes added,
  8509.     // this is for files that are an exact multiple of the chunk
  8510.     // length. (Otherwise the padding isn't Translated)
  8511.     flen += MDxPad( lpData, flen, mlen );
  8512.     MD5Translate( lpData, flen, &mdDataSum );    
  8513.     MD4Translate( lpData, flen, &md4DataSum );
  8514.  
  8515.     // New step necessary because of the 'chunking' method
  8516.     MDxFinalize( &mdDataSum );
  8517.     MDxFinalize( &md4DataSum );
  8518.     
  8519.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8520.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8521.     fclose(file);
  8522.         
  8523. }
  8524.  
  8525. void DigestString()
  8526. {
  8527.     
  8528.     //For our demo purposes, no strings bigger than 1024 :)
  8529.     unsigned char lpData[1024] = "";
  8530.     long len = 0;
  8531.     MDxSum mdDataSum;
  8532.  
  8533.     printf("Enter the string to digest: ");
  8534.     scanf("%s", &lpData );
  8535.     len = strlen(lpData);
  8536.     
  8537.     // Have to do this before the Padding...well...it's best anyway;)
  8538.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8539.     
  8540.     // For the strings, we're gonna pad and digest the string
  8541.     // in one pass.
  8542.     MDxInit( &mdDataSum );
  8543.     MDxPad( lpData, len, len );
  8544.     
  8545.     MD5Translate( lpData, len, &mdDataSum );
  8546.         // New step necessary because of the 'chunking' method
  8547.         MDxFinalize( &mdDataSum );
  8548.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8549.     
  8550.     MDxInit( &mdDataSum );
  8551.     MD4Translate( lpData, len, &mdDataSum );    
  8552.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8553.  
  8554.     return;
  8555. }
  8556.  
  8557.  
  8558. -------------- Include
  8559.  
  8560. #ifndef __windows_h__
  8561.         typedef unsigned long DWORD;
  8562.         #define STDCALL _stdcall
  8563. #endif
  8564.  
  8565. typedef struct 
  8566. {
  8567.     DWORD dwSum[4];
  8568. }MDxSum;
  8569.  
  8570. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  8571. void STDCALL MDxInit( MDxSum * );
  8572. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  8573. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  8574. const char * STDCALL MDxGetVersion();
  8575. void STDCALL MDxFinalize( MDxSum * );
  8576.  
  8577.  
  8578.  
  8579. #include "mdx.h"
  8580. #include <stdlib.h>
  8581. #include <stdio.h>
  8582. #include <string.h>
  8583.  
  8584. // READLEN % 64 must = 0
  8585. #define READLEN    1048576L // 2^20, 1MB
  8586.  
  8587. void DigestFile( char * );
  8588. void DigestString();
  8589.  
  8590. void main(int argc, char *argv[])
  8591. {
  8592.     printf("%s\n\n", MDxGetVersion());
  8593.  
  8594.     if( argc > 1 )
  8595.         DigestFile( argv[1] );
  8596.     else    
  8597.         DigestString();
  8598.  
  8599. }
  8600.  
  8601. /*
  8602.     I use the 'chunk' method for processing files not because of
  8603.     limitations of my dll, but think what would happen if you
  8604.     tried to load an entire cd image into memory.
  8605. */
  8606. void DigestFile( char *szFName )
  8607. {
  8608.     FILE *file;
  8609.     void *lpData;
  8610.     long flen, mlen;
  8611.     MDxSum mdDataSum;
  8612.     MDxSum md4DataSum;
  8613.  
  8614.     // the 64 is for padding purposes
  8615.     lpData = malloc( READLEN + 64 );
  8616.     
  8617.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8618.  
  8619.     file = fopen( szFName, "rb" );
  8620.     if( file == NULL )
  8621.     {
  8622.         printf("ERROR: File not found.\n");
  8623.         return;
  8624.     }
  8625.     
  8626.     MDxInit( &mdDataSum );
  8627.     MDxInit( &md4DataSum );
  8628.     
  8629.     fseek( file, 0, SEEK_END );
  8630.     //Get the file length
  8631.     flen = mlen = ftell( file );
  8632.     fseek( file, 0, SEEK_SET );
  8633.     
  8634.     // When it takes a while to process a large file,
  8635.     // remember that for each chunk it has to run 
  8636.     // through the main translation loop 16384 times!
  8637.         
  8638.     printf("Processing %ld byte file: .", flen );
  8639.     
  8640.     while( flen > READLEN )
  8641.     {
  8642.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8643.         {
  8644.             printf("READ ERROR!\n");
  8645.             return;
  8646.         }
  8647.         MD5Translate( lpData, READLEN, &mdDataSum );
  8648.         MD4Translate( lpData, READLEN, &md4DataSum );
  8649.         flen -= READLEN;
  8650.         printf(".");
  8651.     }
  8652.  
  8653.     if (fread( lpData, 1, flen, file ) != flen)
  8654.     {
  8655.         printf("READ ERROR!\n");
  8656.         return;
  8657.     }
  8658.     // This is why I added the new argument to MDxPad
  8659.     // So we can pass the length of the data AND the
  8660.     // Total length of the message
  8661.     // Also it now returns the # of padding bytes added,
  8662.     // this is for files that are an exact multiple of the chunk
  8663.     // length. (Otherwise the padding isn't Translated)
  8664.     flen += MDxPad( lpData, flen, mlen );
  8665.     MD5Translate( lpData, flen, &mdDataSum );    
  8666.     MD4Translate( lpData, flen, &md4DataSum );
  8667.  
  8668.     // New step necessary because of the 'chunking' method
  8669.     MDxFinalize( &mdDataSum );
  8670.     MDxFinalize( &md4DataSum );
  8671.     
  8672.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8673.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8674.     fclose(file);
  8675.         
  8676. }
  8677.  
  8678. void DigestString()
  8679. {
  8680.     
  8681.     //For our demo purposes, no strings bigger than 1024 :)
  8682.     unsigned char lpData[1024] = "";
  8683.     long len = 0;
  8684.     MDxSum mdDataSum;
  8685.  
  8686.     printf("Enter the string to digest: ");
  8687.     scanf("%s", &lpData );
  8688.     len = strlen(lpData);
  8689.     
  8690.     // Have to do this before the Padding...well...it's best anyway;)
  8691.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8692.     
  8693.     // For the strings, we're gonna pad and digest the string
  8694.     // in one pass.
  8695.     MDxInit( &mdDataSum );
  8696.     MDxPad( lpData, len, len );
  8697.     
  8698.     MD5Translate( lpData, len, &mdDataSum );
  8699.         // New step necessary because of the 'chunking' method
  8700.         MDxFinalize( &mdDataSum );
  8701.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8702.     
  8703.     MDxInit( &mdDataSum );
  8704.     MD4Translate( lpData, len, &mdDataSum );    
  8705.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8706.  
  8707.     return;
  8708. }
  8709.  
  8710.  
  8711. -------------- Include
  8712.  
  8713. #ifndef __windows_h__
  8714.         typedef unsigned long DWORD;
  8715.         #define STDCALL _stdcall
  8716. #endif
  8717.  
  8718. typedef struct 
  8719. {
  8720.     DWORD dwSum[4];
  8721. }MDxSum;
  8722.  
  8723. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  8724. void STDCALL MDxInit( MDxSum * );
  8725. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  8726. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  8727. const char * STDCALL MDxGetVersion();
  8728. void STDCALL MDxFinalize( MDxSum * );
  8729.  
  8730.  
  8731. #include "mdx.h"
  8732. #include <stdlib.h>
  8733. #include <stdio.h>
  8734. #include <string.h>
  8735.  
  8736. // READLEN % 64 must = 0
  8737. #define READLEN    1048576L // 2^20, 1MB
  8738.  
  8739. void DigestFile( char * );
  8740. void DigestString();
  8741.  
  8742. void main(int argc, char *argv[])
  8743. {
  8744.     printf("%s\n\n", MDxGetVersion());
  8745.  
  8746.     if( argc > 1 )
  8747.         DigestFile( argv[1] );
  8748.     else    
  8749.         DigestString();
  8750.  
  8751. }
  8752.  
  8753. /*
  8754.     I use the 'chunk' method for processing files not because of
  8755.     limitations of my dll, but think what would happen if you
  8756.     tried to load an entire cd image into memory.
  8757. */
  8758. void DigestFile( char *szFName )
  8759. {
  8760.     FILE *file;
  8761.     void *lpData;
  8762.     long flen, mlen;
  8763.     MDxSum mdDataSum;
  8764.     MDxSum md4DataSum;
  8765.  
  8766.     // the 64 is for padding purposes
  8767.     lpData = malloc( READLEN + 64 );
  8768.     
  8769.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8770.  
  8771.     file = fopen( szFName, "rb" );
  8772.     if( file == NULL )
  8773.     {
  8774.         printf("ERROR: File not found.\n");
  8775.         return;
  8776.     }
  8777.     
  8778.     MDxInit( &mdDataSum );
  8779.     MDxInit( &md4DataSum );
  8780.     
  8781.     fseek( file, 0, SEEK_END );
  8782.     //Get the file length
  8783.     flen = mlen = ftell( file );
  8784.     fseek( file, 0, SEEK_SET );
  8785.     
  8786.     // When it takes a while to process a large file,
  8787.     // remember that for each chunk it has to run 
  8788.     // through the main translation loop 16384 times!
  8789.         
  8790.     printf("Processing %ld byte file: .", flen );
  8791.     
  8792.     while( flen > READLEN )
  8793.     {
  8794.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8795.         {
  8796.             printf("READ ERROR!\n");
  8797.             return;
  8798.         }
  8799.         MD5Translate( lpData, READLEN, &mdDataSum );
  8800.         MD4Translate( lpData, READLEN, &md4DataSum );
  8801.         flen -= READLEN;
  8802.         printf(".");
  8803.     }
  8804.  
  8805.     if (fread( lpData, 1, flen, file ) != flen)
  8806.     {
  8807.         printf("READ ERROR!\n");
  8808.         return;
  8809.     }
  8810.     // This is why I added the new argument to MDxPad
  8811.     // So we can pass the length of the data AND the
  8812.     // Total length of the message
  8813.     // Also it now returns the # of padding bytes added,
  8814.     // this is for files that are an exact multiple of the chunk
  8815.     // length. (Otherwise the padding isn't Translated)
  8816.     flen += MDxPad( lpData, flen, mlen );
  8817.     MD5Translate( lpData, flen, &mdDataSum );    
  8818.     MD4Translate( lpData, flen, &md4DataSum );
  8819.  
  8820.     // New step necessary because of the 'chunking' method
  8821.     MDxFinalize( &mdDataSum );
  8822.     MDxFinalize( &md4DataSum );
  8823.     
  8824.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8825.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8826.     fclose(file);
  8827.         
  8828. }
  8829.  
  8830. void DigestString()
  8831. {
  8832.     
  8833.     //For our demo purposes, no strings bigger than 1024 :)
  8834.     unsigned char lpData[1024] = "";
  8835.     long len = 0;
  8836.     MDxSum mdDataSum;
  8837.  
  8838.     printf("Enter the string to digest: ");
  8839.     scanf("%s", &lpData );
  8840.     len = strlen(lpData);
  8841.     
  8842.     // Have to do this before the Padding...well...it's best anyway;)
  8843.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8844.     
  8845.     // For the strings, we're gonna pad and digest the string
  8846.     // in one pass.
  8847.     MDxInit( &mdDataSum );
  8848.     MDxPad( lpData, len, len );
  8849.     
  8850.     MD5Translate( lpData, len, &mdDataSum );
  8851.         // New step necessary because of the 'chunking' method
  8852.         MDxFinalize( &mdDataSum );
  8853.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8854.     
  8855.     MDxInit( &mdDataSum );
  8856.     MD4Translate( lpData, len, &mdDataSum );    
  8857.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8858.  
  8859.     return;
  8860. }
  8861.  
  8862.  
  8863. -------------- Include
  8864.  
  8865. #ifndef __windows_h__
  8866.         typedef unsigned long DWORD;
  8867.         #define STDCALL _stdcall
  8868. #endif
  8869.  
  8870. typedef struct 
  8871. {
  8872.     DWORD dwSum[4];
  8873. }MDxSum;
  8874.  
  8875. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  8876. void STDCALL MDxInit( MDxSum * );
  8877. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  8878. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  8879. const char * STDCALL MDxGetVersion();
  8880. void STDCALL MDxFinalize( MDxSum * );
  8881.  
  8882.  
  8883. #include "mdx.h"
  8884. #include <stdlib.h>
  8885. #include <stdio.h>
  8886. #include <string.h>
  8887.  
  8888. // READLEN % 64 must = 0
  8889. #define READLEN    1048576L // 2^20, 1MB
  8890.  
  8891. void DigestFile( char * );
  8892. void DigestString();
  8893.  
  8894. void main(int argc, char *argv[])
  8895. {
  8896.     printf("%s\n\n", MDxGetVersion());
  8897.  
  8898.     if( argc > 1 )
  8899.         DigestFile( argv[1] );
  8900.     else    
  8901.         DigestString();
  8902.  
  8903. }
  8904.  
  8905. /*
  8906.     I use the 'chunk' method for processing files not because of
  8907.     limitations of my dll, but think what would happen if you
  8908.     tried to load an entire cd image into memory.
  8909. */
  8910. void DigestFile( char *szFName )
  8911. {
  8912.     FILE *file;
  8913.     void *lpData;
  8914.     long flen, mlen;
  8915.     MDxSum mdDataSum;
  8916.     MDxSum md4DataSum;
  8917.  
  8918.     // the 64 is for padding purposes
  8919.     lpData = malloc( READLEN + 64 );
  8920.     
  8921.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  8922.  
  8923.     file = fopen( szFName, "rb" );
  8924.     if( file == NULL )
  8925.     {
  8926.         printf("ERROR: File not found.\n");
  8927.         return;
  8928.     }
  8929.     
  8930.     MDxInit( &mdDataSum );
  8931.     MDxInit( &md4DataSum );
  8932.     
  8933.     fseek( file, 0, SEEK_END );
  8934.     //Get the file length
  8935.     flen = mlen = ftell( file );
  8936.     fseek( file, 0, SEEK_SET );
  8937.     
  8938.     // When it takes a while to process a large file,
  8939.     // remember that for each chunk it has to run 
  8940.     // through the main translation loop 16384 times!
  8941.         
  8942.     printf("Processing %ld byte file: .", flen );
  8943.     
  8944.     while( flen > READLEN )
  8945.     {
  8946.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  8947.         {
  8948.             printf("READ ERROR!\n");
  8949.             return;
  8950.         }
  8951.         MD5Translate( lpData, READLEN, &mdDataSum );
  8952.         MD4Translate( lpData, READLEN, &md4DataSum );
  8953.         flen -= READLEN;
  8954.         printf(".");
  8955.     }
  8956.  
  8957.     if (fread( lpData, 1, flen, file ) != flen)
  8958.     {
  8959.         printf("READ ERROR!\n");
  8960.         return;
  8961.     }
  8962.     // This is why I added the new argument to MDxPad
  8963.     // So we can pass the length of the data AND the
  8964.     // Total length of the message
  8965.     // Also it now returns the # of padding bytes added,
  8966.     // this is for files that are an exact multiple of the chunk
  8967.     // length. (Otherwise the padding isn't Translated)
  8968.     flen += MDxPad( lpData, flen, mlen );
  8969.     MD5Translate( lpData, flen, &mdDataSum );    
  8970.     MD4Translate( lpData, flen, &md4DataSum );
  8971.  
  8972.     // New step necessary because of the 'chunking' method
  8973.     MDxFinalize( &mdDataSum );
  8974.     MDxFinalize( &md4DataSum );
  8975.     
  8976.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  8977.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  8978.     fclose(file);
  8979.         
  8980. }
  8981.  
  8982. void DigestString()
  8983. {
  8984.     
  8985.     //For our demo purposes, no strings bigger than 1024 :)
  8986.     unsigned char lpData[1024] = "";
  8987.     long len = 0;
  8988.     MDxSum mdDataSum;
  8989.  
  8990.     printf("Enter the string to digest: ");
  8991.     scanf("%s", &lpData );
  8992.     len = strlen(lpData);
  8993.     
  8994.     // Have to do this before the Padding...well...it's best anyway;)
  8995.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  8996.     
  8997.     // For the strings, we're gonna pad and digest the string
  8998.     // in one pass.
  8999.     MDxInit( &mdDataSum );
  9000.     MDxPad( lpData, len, len );
  9001.     
  9002.     MD5Translate( lpData, len, &mdDataSum );
  9003.         // New step necessary because of the 'chunking' method
  9004.         MDxFinalize( &mdDataSum );
  9005.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9006.     
  9007.     MDxInit( &mdDataSum );
  9008.     MD4Translate( lpData, len, &mdDataSum );    
  9009.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9010.  
  9011.     return;
  9012. }
  9013.  
  9014.  
  9015. -------------- Include
  9016.  
  9017. #ifndef __windows_h__
  9018.         typedef unsigned long DWORD;
  9019.         #define STDCALL _stdcall
  9020. #endif
  9021.  
  9022. typedef struct 
  9023. {
  9024.     DWORD dwSum[4];
  9025. }MDxSum;
  9026.  
  9027. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9028. void STDCALL MDxInit( MDxSum * );
  9029. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9030. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9031. const char * STDCALL MDxGetVersion();
  9032. void STDCALL MDxFinalize( MDxSum * );
  9033.  
  9034.  
  9035.  
  9036. #include "mdx.h"
  9037. #include <stdlib.h>
  9038. #include <stdio.h>
  9039. #include <string.h>
  9040.  
  9041. // READLEN % 64 must = 0
  9042. #define READLEN    1048576L // 2^20, 1MB
  9043.  
  9044. void DigestFile( char * );
  9045. void DigestString();
  9046.  
  9047. void main(int argc, char *argv[])
  9048. {
  9049.     printf("%s\n\n", MDxGetVersion());
  9050.  
  9051.     if( argc > 1 )
  9052.         DigestFile( argv[1] );
  9053.     else    
  9054.         DigestString();
  9055.  
  9056. }
  9057.  
  9058. /*
  9059.     I use the 'chunk' method for processing files not because of
  9060.     limitations of my dll, but think what would happen if you
  9061.     tried to load an entire cd image into memory.
  9062. */
  9063. void DigestFile( char *szFName )
  9064. {
  9065.     FILE *file;
  9066.     void *lpData;
  9067.     long flen, mlen;
  9068.     MDxSum mdDataSum;
  9069.     MDxSum md4DataSum;
  9070.  
  9071.     // the 64 is for padding purposes
  9072.     lpData = malloc( READLEN + 64 );
  9073.     
  9074.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9075.  
  9076.     file = fopen( szFName, "rb" );
  9077.     if( file == NULL )
  9078.     {
  9079.         printf("ERROR: File not found.\n");
  9080.         return;
  9081.     }
  9082.     
  9083.     MDxInit( &mdDataSum );
  9084.     MDxInit( &md4DataSum );
  9085.     
  9086.     fseek( file, 0, SEEK_END );
  9087.     //Get the file length
  9088.     flen = mlen = ftell( file );
  9089.     fseek( file, 0, SEEK_SET );
  9090.     
  9091.     // When it takes a while to process a large file,
  9092.     // remember that for each chunk it has to run 
  9093.     // through the main translation loop 16384 times!
  9094.         
  9095.     printf("Processing %ld byte file: .", flen );
  9096.     
  9097.     while( flen > READLEN )
  9098.     {
  9099.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  9100.         {
  9101.             printf("READ ERROR!\n");
  9102.             return;
  9103.         }
  9104.         MD5Translate( lpData, READLEN, &mdDataSum );
  9105.         MD4Translate( lpData, READLEN, &md4DataSum );
  9106.         flen -= READLEN;
  9107.         printf(".");
  9108.     }
  9109.  
  9110.     if (fread( lpData, 1, flen, file ) != flen)
  9111.     {
  9112.         printf("READ ERROR!\n");
  9113.         return;
  9114.     }
  9115.     // This is why I added the new argument to MDxPad
  9116.     // So we can pass the length of the data AND the
  9117.     // Total length of the message
  9118.     // Also it now returns the # of padding bytes added,
  9119.     // this is for files that are an exact multiple of the chunk
  9120.     // length. (Otherwise the padding isn't Translated)
  9121.     flen += MDxPad( lpData, flen, mlen );
  9122.     MD5Translate( lpData, flen, &mdDataSum );    
  9123.     MD4Translate( lpData, flen, &md4DataSum );
  9124.  
  9125.     // New step necessary because of the 'chunking' method
  9126.     MDxFinalize( &mdDataSum );
  9127.     MDxFinalize( &md4DataSum );
  9128.     
  9129.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  9130.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9131.     fclose(file);
  9132.         
  9133. }
  9134.  
  9135. void DigestString()
  9136. {
  9137.     
  9138.     //For our demo purposes, no strings bigger than 1024 :)
  9139.     unsigned char lpData[1024] = "";
  9140.     long len = 0;
  9141.     MDxSum mdDataSum;
  9142.  
  9143.     printf("Enter the string to digest: ");
  9144.     scanf("%s", &lpData );
  9145.     len = strlen(lpData);
  9146.     
  9147.     // Have to do this before the Padding...well...it's best anyway;)
  9148.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  9149.     
  9150.     // For the strings, we're gonna pad and digest the string
  9151.     // in one pass.
  9152.     MDxInit( &mdDataSum );
  9153.     MDxPad( lpData, len, len );
  9154.     
  9155.     MD5Translate( lpData, len, &mdDataSum );
  9156.         // New step necessary because of the 'chunking' method
  9157.         MDxFinalize( &mdDataSum );
  9158.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9159.     
  9160.     MDxInit( &mdDataSum );
  9161.     MD4Translate( lpData, len, &mdDataSum );    
  9162.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9163.  
  9164.     return;
  9165. }
  9166.  
  9167.  
  9168. -------------- Include
  9169.  
  9170. #ifndef __windows_h__
  9171.         typedef unsigned long DWORD;
  9172.         #define STDCALL _stdcall
  9173. #endif
  9174.  
  9175. typedef struct 
  9176. {
  9177.     DWORD dwSum[4];
  9178. }MDxSum;
  9179.  
  9180. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9181. void STDCALL MDxInit( MDxSum * );
  9182. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9183. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9184. const char * STDCALL MDxGetVersion();
  9185. void STDCALL MDxFinalize( MDxSum * );
  9186.  
  9187.  
  9188.  
  9189. #include "mdx.h"
  9190. #include <stdlib.h>
  9191. #include <stdio.h>
  9192. #include <string.h>
  9193.  
  9194. // READLEN % 64 must = 0
  9195. #define READLEN    1048576L // 2^20, 1MB
  9196.  
  9197. void DigestFile( char * );
  9198. void DigestString();
  9199.  
  9200. void main(int argc, char *argv[])
  9201. {
  9202.     printf("%s\n\n", MDxGetVersion());
  9203.  
  9204.     if( argc > 1 )
  9205.         DigestFile( argv[1] );
  9206.     else    
  9207.         DigestString();
  9208.  
  9209. }
  9210.  
  9211. /*
  9212.     I use the 'chunk' method for processing files not because of
  9213.     limitations of my dll, but think what would happen if you
  9214.     tried to load an entire cd image into memory.
  9215. */
  9216. void DigestFile( char *szFName )
  9217. {
  9218.     FILE *file;
  9219.     void *lpData;
  9220.     long flen, mlen;
  9221.     MDxSum mdDataSum;
  9222.     MDxSum md4DataSum;
  9223.  
  9224.     // the 64 is for padding purposes
  9225.     lpData = malloc( READLEN + 64 );
  9226.     
  9227.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9228.  
  9229.     file = fopen( szFName, "rb" );
  9230.     if( file == NULL )
  9231.     {
  9232.         printf("ERROR: File not found.\n");
  9233.         return;
  9234.     }
  9235.     
  9236.     MDxInit( &mdDataSum );
  9237.     MDxInit( &md4DataSum );
  9238.     
  9239.     fseek( file, 0, SEEK_END );
  9240.     //Get the file length
  9241.     flen = mlen = ftell( file );
  9242.     fseek( file, 0, SEEK_SET );
  9243.     
  9244.     // When it takes a while to process a large file,
  9245.     // remember that for each chunk it has to run 
  9246.     // through the main translation loop 16384 times!
  9247.         
  9248.     printf("Processing %ld byte file: .", flen );
  9249.     
  9250.     while( flen > READLEN )
  9251.     {
  9252.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  9253.         {
  9254.             printf("READ ERROR!\n");
  9255.             return;
  9256.         }
  9257.         MD5Translate( lpData, READLEN, &mdDataSum );
  9258.         MD4Translate( lpData, READLEN, &md4DataSum );
  9259.         flen -= READLEN;
  9260.         printf(".");
  9261.     }
  9262.  
  9263.     if (fread( lpData, 1, flen, file ) != flen)
  9264.     {
  9265.         printf("READ ERROR!\n");
  9266.         return;
  9267.     }
  9268.     // This is why I added the new argument to MDxPad
  9269.     // So we can pass the length of the data AND the
  9270.     // Total length of the message
  9271.     // Also it now returns the # of padding bytes added,
  9272.     // this is for files that are an exact multiple of the chunk
  9273.     // length. (Otherwise the padding isn't Translated)
  9274.     flen += MDxPad( lpData, flen, mlen );
  9275.     MD5Translate( lpData, flen, &mdDataSum );    
  9276.     MD4Translate( lpData, flen, &md4DataSum );
  9277.  
  9278.     // New step necessary because of the 'chunking' method
  9279.     MDxFinalize( &mdDataSum );
  9280.     MDxFinalize( &md4DataSum );
  9281.     
  9282.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  9283.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9284.     fclose(file);
  9285.         
  9286. }
  9287.  
  9288. void DigestString()
  9289. {
  9290.     
  9291.     //For our demo purposes, no strings bigger than 1024 :)
  9292.     unsigned char lpData[1024] = "";
  9293.     long len = 0;
  9294.     MDxSum mdDataSum;
  9295.  
  9296.     printf("Enter the string to digest: ");
  9297.     scanf("%s", &lpData );
  9298.     len = strlen(lpData);
  9299.     
  9300.     // Have to do this before the Padding...well...it's best anyway;)
  9301.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  9302.     
  9303.     // For the strings, we're gonna pad and digest the string
  9304.     // in one pass.
  9305.     MDxInit( &mdDataSum );
  9306.     MDxPad( lpData, len, len );
  9307.     
  9308.     MD5Translate( lpData, len, &mdDataSum );
  9309.         // New step necessary because of the 'chunking' method
  9310.         MDxFinalize( &mdDataSum );
  9311.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9312.     
  9313.     MDxInit( &mdDataSum );
  9314.     MD4Translate( lpData, len, &mdDataSum );    
  9315.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9316.  
  9317.     return;
  9318. }
  9319.  
  9320.  
  9321. -------------- Include
  9322.  
  9323. #ifndef __windows_h__
  9324.         typedef unsigned long DWORD;
  9325.         #define STDCALL _stdcall
  9326. #endif
  9327.  
  9328. typedef struct 
  9329. {
  9330.     DWORD dwSum[4];
  9331. }MDxSum;
  9332.  
  9333. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9334. void STDCALL MDxInit( MDxSum * );
  9335. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9336. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9337. const char * STDCALL MDxGetVersion();
  9338. void STDCALL MDxFinalize( MDxSum * );
  9339.  
  9340.  
  9341.  
  9342. #include "mdx.h"
  9343. #include <stdlib.h>
  9344. #include <stdio.h>
  9345. #include <string.h>
  9346.  
  9347. // READLEN % 64 must = 0
  9348. #define READLEN    1048576L // 2^20, 1MB
  9349.  
  9350. void DigestFile( char * );
  9351. void DigestString();
  9352.  
  9353. void main(int argc, char *argv[])
  9354. {
  9355.     printf("%s\n\n", MDxGetVersion());
  9356.  
  9357.     if( argc > 1 )
  9358.         DigestFile( argv[1] );
  9359.     else    
  9360.         DigestString();
  9361.  
  9362. }
  9363.  
  9364. /*
  9365.     I use the 'chunk' method for processing files not because of
  9366.     limitations of my dll, but think what would happen if you
  9367.     tried to load an entire cd image into memory.
  9368. */
  9369. void DigestFile( char *szFName )
  9370. {
  9371.     FILE *file;
  9372.     void *lpData;
  9373.     long flen, mlen;
  9374.     MDxSum mdDataSum;
  9375.     MDxSum md4DataSum;
  9376.  
  9377.     // the 64 is for padding purposes
  9378.     lpData = malloc( READLEN + 64 );
  9379.     
  9380.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9381.  
  9382.     file = fopen( szFName, "rb" );
  9383.     if( file == NULL )
  9384.     {
  9385.         printf("ERROR: File not found.\n");
  9386.         return;
  9387.     }
  9388.     
  9389.     MDxInit( &mdDataSum );
  9390.     MDxInit( &md4DataSum );
  9391.     
  9392.     fseek( file, 0, SEEK_END );
  9393.     //Get the file length
  9394.     flen = mlen = ftell( file );
  9395.     fseek( file, 0, SEEK_SET );
  9396.     
  9397.     // When it takes a while to process a large file,
  9398.     // remember that for each chunk it has to run 
  9399.     // through the main translation loop 16384 times!
  9400.         
  9401.     printf("Processing %ld byte file: .", flen );
  9402.     
  9403.     while( flen > READLEN )
  9404.     {
  9405.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  9406.         {
  9407.             printf("READ ERROR!\n");
  9408.             return;
  9409.         }
  9410.         MD5Translate( lpData, READLEN, &mdDataSum );
  9411.         MD4Translate( lpData, READLEN, &md4DataSum );
  9412.         flen -= READLEN;
  9413.         printf(".");
  9414.     }
  9415.  
  9416.     if (fread( lpData, 1, flen, file ) != flen)
  9417.     {
  9418.         printf("READ ERROR!\n");
  9419.         return;
  9420.     }
  9421.     // This is why I added the new argument to MDxPad
  9422.     // So we can pass the length of the data AND the
  9423.     // Total length of the message
  9424.     // Also it now returns the # of padding bytes added,
  9425.     // this is for files that are an exact multiple of the chunk
  9426.     // length. (Otherwise the padding isn't Translated)
  9427.     flen += MDxPad( lpData, flen, mlen );
  9428.     MD5Translate( lpData, flen, &mdDataSum );    
  9429.     MD4Translate( lpData, flen, &md4DataSum );
  9430.  
  9431.     // New step necessary because of the 'chunking' method
  9432.     MDxFinalize( &mdDataSum );
  9433.     MDxFinalize( &md4DataSum );
  9434.     
  9435.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  9436.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9437.     fclose(file);
  9438.         
  9439. }
  9440.  
  9441. void DigestString()
  9442. {
  9443.     
  9444.     //For our demo purposes, no strings bigger than 1024 :)
  9445.     unsigned char lpData[1024] = "";
  9446.     long len = 0;
  9447.     MDxSum mdDataSum;
  9448.  
  9449.     printf("Enter the string to digest: ");
  9450.     scanf("%s", &lpData );
  9451.     len = strlen(lpData);
  9452.     
  9453.     // Have to do this before the Padding...well...it's best anyway;)
  9454.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  9455.     
  9456.     // For the strings, we're gonna pad and digest the string
  9457.     // in one pass.
  9458.     MDxInit( &mdDataSum );
  9459.     MDxPad( lpData, len, len );
  9460.     
  9461.     MD5Translate( lpData, len, &mdDataSum );
  9462.         // New step necessary because of the 'chunking' method
  9463.         MDxFinalize( &mdDataSum );
  9464.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9465.     
  9466.     MDxInit( &mdDataSum );
  9467.     MD4Translate( lpData, len, &mdDataSum );    
  9468.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9469.  
  9470.     return;
  9471. }
  9472.  
  9473.  
  9474. -------------- Include
  9475.  
  9476. #ifndef __windows_h__
  9477.         typedef unsigned long DWORD;
  9478.         #define STDCALL _stdcall
  9479. #endif
  9480.  
  9481. typedef struct 
  9482. {
  9483.     DWORD dwSum[4];
  9484. }MDxSum;
  9485.  
  9486. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9487. void STDCALL MDxInit( MDxSum * );
  9488. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9489. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9490. const char * STDCALL MDxGetVersion();
  9491. void STDCALL MDxFinalize( MDxSum * );
  9492.  
  9493.  
  9494.  
  9495. #include "mdx.h"
  9496. #include <stdlib.h>
  9497. #include <stdio.h>
  9498. #include <string.h>
  9499.  
  9500. // READLEN % 64 must = 0
  9501. #define READLEN    1048576L // 2^20, 1MB
  9502.  
  9503. void DigestFile( char * );
  9504. void DigestString();
  9505.  
  9506. void main(int argc, char *argv[])
  9507. {
  9508.     printf("%s\n\n", MDxGetVersion());
  9509.  
  9510.     if( argc > 1 )
  9511.         DigestFile( argv[1] );
  9512.     else    
  9513.         DigestString();
  9514.  
  9515. }
  9516.  
  9517. /*
  9518.     I use the 'chunk' method for processing files not because of
  9519.     limitations of my dll, but think what would happen if you
  9520.     tried to load an entire cd image into memory.
  9521. */
  9522. void DigestFile( char *szFName )
  9523. {
  9524.     FILE *file;
  9525.     void *lpData;
  9526.     long flen, mlen;
  9527.     MDxSum mdDataSum;
  9528.     MDxSum md4DataSum;
  9529.  
  9530.     // the 64 is for padding purposes
  9531.     lpData = malloc( READLEN + 64 );
  9532.     
  9533.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9534.  
  9535.     file = fopen( szFName, "rb" );
  9536.     if( file == NULL )
  9537.     {
  9538.         printf("ERROR: File not found.\n");
  9539.         return;
  9540.     }
  9541.     
  9542.     MDxInit( &mdDataSum );
  9543.     MDxInit( &md4DataSum );
  9544.     
  9545.     fseek( file, 0, SEEK_END );
  9546.     //Get the file length
  9547.     flen = mlen = ftell( file );
  9548.     fseek( file, 0, SEEK_SET );
  9549.     
  9550.     // When it takes a while to process a large file,
  9551.     // remember that for each chunk it has to run 
  9552.     // through the main translation loop 16384 times!
  9553.         
  9554.     printf("Processing %ld byte file: .", flen );
  9555.     
  9556.     while( flen > READLEN )
  9557.     {
  9558.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  9559.         {
  9560.             printf("READ ERROR!\n");
  9561.             return;
  9562.         }
  9563.         MD5Translate( lpData, READLEN, &mdDataSum );
  9564.         MD4Translate( lpData, READLEN, &md4DataSum );
  9565.         flen -= READLEN;
  9566.         printf(".");
  9567.     }
  9568.  
  9569.     if (fread( lpData, 1, flen, file ) != flen)
  9570.     {
  9571.         printf("READ ERROR!\n");
  9572.         return;
  9573.     }
  9574.     // This is why I added the new argument to MDxPad
  9575.     // So we can pass the length of the data AND the
  9576.     // Total length of the message
  9577.     // Also it now returns the # of padding bytes added,
  9578.     // this is for files that are an exact multiple of the chunk
  9579.     // length. (Otherwise the padding isn't Translated)
  9580.     flen += MDxPad( lpData, flen, mlen );
  9581.     MD5Translate( lpData, flen, &mdDataSum );    
  9582.     MD4Translate( lpData, flen, &md4DataSum );
  9583.  
  9584.     // New step necessary because of the 'chunking' method
  9585.     MDxFinalize( &mdDataSum );
  9586.     MDxFinalize( &md4DataSum );
  9587.     
  9588.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  9589.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9590.     fclose(file);
  9591.         
  9592. }
  9593.  
  9594. void DigestString()
  9595. {
  9596.     
  9597.     //For our demo purposes, no strings bigger than 1024 :)
  9598.     unsigned char lpData[1024] = "";
  9599.     long len = 0;
  9600.     MDxSum mdDataSum;
  9601.  
  9602.     printf("Enter the string to digest: ");
  9603.     scanf("%s", &lpData );
  9604.     len = strlen(lpData);
  9605.     
  9606.     // Have to do this before the Padding...well...it's best anyway;)
  9607.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  9608.     
  9609.     // For the strings, we're gonna pad and digest the string
  9610.     // in one pass.
  9611.     MDxInit( &mdDataSum );
  9612.     MDxPad( lpData, len, len );
  9613.     
  9614.     MD5Translate( lpData, len, &mdDataSum );
  9615.         // New step necessary because of the 'chunking' method
  9616.         MDxFinalize( &mdDataSum );
  9617.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9618.     
  9619.     MDxInit( &mdDataSum );
  9620.     MD4Translate( lpData, len, &mdDataSum );    
  9621.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9622.  
  9623.     return;
  9624. }
  9625.  
  9626.  
  9627. -------------- Include
  9628.  
  9629. #ifndef __windows_h__
  9630.         typedef unsigned long DWORD;
  9631.         #define STDCALL _stdcall
  9632. #endif
  9633.  
  9634. typedef struct 
  9635. {
  9636.     DWORD dwSum[4];
  9637. }MDxSum;
  9638.  
  9639. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9640. void STDCALL MDxInit( MDxSum * );
  9641. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9642. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9643. const char * STDCALL MDxGetVersion();
  9644. void STDCALL MDxFinalize( MDxSum * );
  9645.  
  9646.  
  9647.  
  9648. #include "mdx.h"
  9649. #include <stdlib.h>
  9650. #include <stdio.h>
  9651. #include <string.h>
  9652.  
  9653. // READLEN % 64 must = 0
  9654. #define READLEN    1048576L // 2^20, 1MB
  9655.  
  9656. void DigestFile( char * );
  9657. void DigestString();
  9658.  
  9659. void main(int argc, char *argv[])
  9660. {
  9661.     printf("%s\n\n", MDxGetVersion());
  9662.  
  9663.     if( argc > 1 )
  9664.         DigestFile( argv[1] );
  9665.     else    
  9666.         DigestString();
  9667.  
  9668. }
  9669.  
  9670. /*
  9671.     I use the 'chunk' method for processing files not because of
  9672.     limitations of my dll, but think what would happen if you
  9673.     tried to load an entire cd image into memory.
  9674. */
  9675. void DigestFile( char *szFName )
  9676. {
  9677.     FILE *file;
  9678.     void *lpData;
  9679.     long flen, mlen;
  9680.     MDxSum mdDataSum;
  9681.     MDxSum md4DataSum;
  9682.  
  9683.     // the 64 is for padding purposes
  9684.     lpData = malloc( READLEN + 64 );
  9685.     
  9686.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9687.  
  9688.     file = fopen( szFName, "rb" );
  9689.     if( file == NULL )
  9690.     {
  9691.         printf("ERROR: File not found.\n");
  9692.         return;
  9693.     }
  9694.     
  9695.     MDxInit( &mdDataSum );
  9696.     MDxInit( &md4DataSum );
  9697.     
  9698.     fseek( file, 0, SEEK_END );
  9699.     //Get the file length
  9700.     flen = mlen = ftell( file );
  9701.     fseek( file, 0, SEEK_SET );
  9702.     
  9703.     // When it takes a while to process a large file,
  9704.     // remember that for each chunk it has to run 
  9705.     // through the main translation loop 16384 times!
  9706.         
  9707.     printf("Processing %ld byte file: .", flen );
  9708.     
  9709.     while( flen > READLEN )
  9710.     {
  9711.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  9712.         {
  9713.             printf("READ ERROR!\n");
  9714.             return;
  9715.         }
  9716.         MD5Translate( lpData, READLEN, &mdDataSum );
  9717.         MD4Translate( lpData, READLEN, &md4DataSum );
  9718.         flen -= READLEN;
  9719.         printf(".");
  9720.     }
  9721.  
  9722.     if (fread( lpData, 1, flen, file ) != flen)
  9723.     {
  9724.         printf("READ ERROR!\n");
  9725.         return;
  9726.     }
  9727.     // This is why I added the new argument to MDxPad
  9728.     // So we can pass the length of the data AND the
  9729.     // Total length of the message
  9730.     // Also it now returns the # of padding bytes added,
  9731.     // this is for files that are an exact multiple of the chunk
  9732.     // length. (Otherwise the padding isn't Translated)
  9733.     flen += MDxPad( lpData, flen, mlen );
  9734.     MD5Translate( lpData, flen, &mdDataSum );    
  9735.     MD4Translate( lpData, flen, &md4DataSum );
  9736.  
  9737.     // New step necessary because of the 'chunking' method
  9738.     MDxFinalize( &mdDataSum );
  9739.     MDxFinalize( &md4DataSum );
  9740.     
  9741.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  9742.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9743.     fclose(file);
  9744.         
  9745. }
  9746.  
  9747. void DigestString()
  9748. {
  9749.     
  9750.     //For our demo purposes, no strings bigger than 1024 :)
  9751.     unsigned char lpData[1024] = "";
  9752.     long len = 0;
  9753.     MDxSum mdDataSum;
  9754.  
  9755.     printf("Enter the string to digest: ");
  9756.     scanf("%s", &lpData );
  9757.     len = strlen(lpData);
  9758.     
  9759.     // Have to do this before the Padding...well...it's best anyway;)
  9760.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  9761.     
  9762.     // For the strings, we're gonna pad and digest the string
  9763.     // in one pass.
  9764.     MDxInit( &mdDataSum );
  9765.     MDxPad( lpData, len, len );
  9766.     
  9767.     MD5Translate( lpData, len, &mdDataSum );
  9768.         // New step necessary because of the 'chunking' method
  9769.         MDxFinalize( &mdDataSum );
  9770.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9771.     
  9772.     MDxInit( &mdDataSum );
  9773.     MD4Translate( lpData, len, &mdDataSum );    
  9774.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9775.  
  9776.     return;
  9777. }
  9778.  
  9779.  
  9780. -------------- Include
  9781.  
  9782. #ifndef __windows_h__
  9783.         typedef unsigned long DWORD;
  9784.         #define STDCALL _stdcall
  9785. #endif
  9786.  
  9787. typedef struct 
  9788. {
  9789.     DWORD dwSum[4];
  9790. }MDxSum;
  9791.  
  9792. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9793. void STDCALL MDxInit( MDxSum * );
  9794. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9795. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9796. const char * STDCALL MDxGetVersion();
  9797. void STDCALL MDxFinalize( MDxSum * );
  9798.  
  9799.  
  9800.  
  9801. #include "mdx.h"
  9802. #include <stdlib.h>
  9803. #include <stdio.h>
  9804. #include <string.h>
  9805.  
  9806. // READLEN % 64 must = 0
  9807. #define READLEN    1048576L // 2^20, 1MB
  9808.  
  9809. void DigestFile( char * );
  9810. void DigestString();
  9811.  
  9812. void main(int argc, char *argv[])
  9813. {
  9814.     printf("%s\n\n", MDxGetVersion());
  9815.  
  9816.     if( argc > 1 )
  9817.         DigestFile( argv[1] );
  9818.     else    
  9819.         DigestString();
  9820.  
  9821. }
  9822.  
  9823. /*
  9824.     I use the 'chunk' method for processing files not because of
  9825.     limitations of my dll, but think what would happen if you
  9826.     tried to load an entire cd image into memory.
  9827. */
  9828. void DigestFile( char *szFName )
  9829. {
  9830.     FILE *file;
  9831.     void *lpData;
  9832.     long flen, mlen;
  9833.     MDxSum mdDataSum;
  9834.     MDxSum md4DataSum;
  9835.  
  9836.     // the 64 is for padding purposes
  9837.     lpData = malloc( READLEN + 64 );
  9838.     
  9839.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9840.  
  9841.     file = fopen( szFName, "rb" );
  9842.     if( file == NULL )
  9843.     {
  9844.         printf("ERROR: File not found.\n");
  9845.         return;
  9846.     }
  9847.     
  9848.     MDxInit( &mdDataSum );
  9849.     MDxInit( &md4DataSum );
  9850.     
  9851.     fseek( file, 0, SEEK_END );
  9852.     //Get the file length
  9853.     flen = mlen = ftell( file );
  9854.     fseek( file, 0, SEEK_SET );
  9855.     
  9856.     // When it takes a while to process a large file,
  9857.     // remember that for each chunk it has to run 
  9858.     // through the main translation loop 16384 times!
  9859.         
  9860.     printf("Processing %ld byte file: .", flen );
  9861.     
  9862.     while( flen > READLEN )
  9863.     {
  9864.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  9865.         {
  9866.             printf("READ ERROR!\n");
  9867.             return;
  9868.         }
  9869.         MD5Translate( lpData, READLEN, &mdDataSum );
  9870.         MD4Translate( lpData, READLEN, &md4DataSum );
  9871.         flen -= READLEN;
  9872.         printf(".");
  9873.     }
  9874.  
  9875.     if (fread( lpData, 1, flen, file ) != flen)
  9876.     {
  9877.         printf("READ ERROR!\n");
  9878.         return;
  9879.     }
  9880.     // This is why I added the new argument to MDxPad
  9881.     // So we can pass the length of the data AND the
  9882.     // Total length of the message
  9883.     // Also it now returns the # of padding bytes added,
  9884.     // this is for files that are an exact multiple of the chunk
  9885.     // length. (Otherwise the padding isn't Translated)
  9886.     flen += MDxPad( lpData, flen, mlen );
  9887.     MD5Translate( lpData, flen, &mdDataSum );    
  9888.     MD4Translate( lpData, flen, &md4DataSum );
  9889.  
  9890.     // New step necessary because of the 'chunking' method
  9891.     MDxFinalize( &mdDataSum );
  9892.     MDxFinalize( &md4DataSum );
  9893.     
  9894.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  9895.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9896.     fclose(file);
  9897.         
  9898. }
  9899.  
  9900. void DigestString()
  9901. {
  9902.     
  9903.     //For our demo purposes, no strings bigger than 1024 :)
  9904.     unsigned char lpData[1024] = "";
  9905.     long len = 0;
  9906.     MDxSum mdDataSum;
  9907.  
  9908.     printf("Enter the string to digest: ");
  9909.     scanf("%s", &lpData );
  9910.     len = strlen(lpData);
  9911.     
  9912.     // Have to do this before the Padding...well...it's best anyway;)
  9913.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  9914.     
  9915.     // For the strings, we're gonna pad and digest the string
  9916.     // in one pass.
  9917.     MDxInit( &mdDataSum );
  9918.     MDxPad( lpData, len, len );
  9919.     
  9920.     MD5Translate( lpData, len, &mdDataSum );
  9921.         // New step necessary because of the 'chunking' method
  9922.         MDxFinalize( &mdDataSum );
  9923.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9924.     
  9925.     MDxInit( &mdDataSum );
  9926.     MD4Translate( lpData, len, &mdDataSum );    
  9927.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  9928.  
  9929.     return;
  9930. }
  9931.  
  9932.  
  9933. -------------- Include
  9934.  
  9935. #ifndef __windows_h__
  9936.         typedef unsigned long DWORD;
  9937.         #define STDCALL _stdcall
  9938. #endif
  9939.  
  9940. typedef struct 
  9941. {
  9942.     DWORD dwSum[4];
  9943. }MDxSum;
  9944.  
  9945. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  9946. void STDCALL MDxInit( MDxSum * );
  9947. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  9948. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  9949. const char * STDCALL MDxGetVersion();
  9950. void STDCALL MDxFinalize( MDxSum * );
  9951.  
  9952.  
  9953.  
  9954. #include "mdx.h"
  9955. #include <stdlib.h>
  9956. #include <stdio.h>
  9957. #include <string.h>
  9958.  
  9959. // READLEN % 64 must = 0
  9960. #define READLEN    1048576L // 2^20, 1MB
  9961.  
  9962. void DigestFile( char * );
  9963. void DigestString();
  9964.  
  9965. void main(int argc, char *argv[])
  9966. {
  9967.     printf("%s\n\n", MDxGetVersion());
  9968.  
  9969.     if( argc > 1 )
  9970.         DigestFile( argv[1] );
  9971.     else    
  9972.         DigestString();
  9973.  
  9974. }
  9975.  
  9976. /*
  9977.     I use the 'chunk' method for processing files not because of
  9978.     limitations of my dll, but think what would happen if you
  9979.     tried to load an entire cd image into memory.
  9980. */
  9981. void DigestFile( char *szFName )
  9982. {
  9983.     FILE *file;
  9984.     void *lpData;
  9985.     long flen, mlen;
  9986.     MDxSum mdDataSum;
  9987.     MDxSum md4DataSum;
  9988.  
  9989.     // the 64 is for padding purposes
  9990.     lpData = malloc( READLEN + 64 );
  9991.     
  9992.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  9993.  
  9994.     file = fopen( szFName, "rb" );
  9995.     if( file == NULL )
  9996.     {
  9997.         printf("ERROR: File not found.\n");
  9998.         return;
  9999.     }
  10000.     
  10001.     MDxInit( &mdDataSum );
  10002.     MDxInit( &md4DataSum );
  10003.     
  10004.     fseek( file, 0, SEEK_END );
  10005.     //Get the file length
  10006.     flen = mlen = ftell( file );
  10007.     fseek( file, 0, SEEK_SET );
  10008.     
  10009.     // When it takes a while to process a large file,
  10010.     // remember that for each chunk it has to run 
  10011.     // through the main translation loop 16384 times!
  10012.         
  10013.     printf("Processing %ld byte file: .", flen );
  10014.     
  10015.     while( flen > READLEN )
  10016.     {
  10017.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10018.         {
  10019.             printf("READ ERROR!\n");
  10020.             return;
  10021.         }
  10022.         MD5Translate( lpData, READLEN, &mdDataSum );
  10023.         MD4Translate( lpData, READLEN, &md4DataSum );
  10024.         flen -= READLEN;
  10025.         printf(".");
  10026.     }
  10027.  
  10028.     if (fread( lpData, 1, flen, file ) != flen)
  10029.     {
  10030.         printf("READ ERROR!\n");
  10031.         return;
  10032.     }
  10033.     // This is why I added the new argument to MDxPad
  10034.     // So we can pass the length of the data AND the
  10035.     // Total length of the message
  10036.     // Also it now returns the # of padding bytes added,
  10037.     // this is for files that are an exact multiple of the chunk
  10038.     // length. (Otherwise the padding isn't Translated)
  10039.     flen += MDxPad( lpData, flen, mlen );
  10040.     MD5Translate( lpData, flen, &mdDataSum );    
  10041.     MD4Translate( lpData, flen, &md4DataSum );
  10042.  
  10043.     // New step necessary because of the 'chunking' method
  10044.     MDxFinalize( &mdDataSum );
  10045.     MDxFinalize( &md4DataSum );
  10046.     
  10047.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10048.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10049.     fclose(file);
  10050.         
  10051. }
  10052.  
  10053. void DigestString()
  10054. {
  10055.     
  10056.     //For our demo purposes, no strings bigger than 1024 :)
  10057.     unsigned char lpData[1024] = "";
  10058.     long len = 0;
  10059.     MDxSum mdDataSum;
  10060.  
  10061.     printf("Enter the string to digest: ");
  10062.     scanf("%s", &lpData );
  10063.     len = strlen(lpData);
  10064.     
  10065.     // Have to do this before the Padding...well...it's best anyway;)
  10066.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10067.     
  10068.     // For the strings, we're gonna pad and digest the string
  10069.     // in one pass.
  10070.     MDxInit( &mdDataSum );
  10071.     MDxPad( lpData, len, len );
  10072.     
  10073.     MD5Translate( lpData, len, &mdDataSum );
  10074.         // New step necessary because of the 'chunking' method
  10075.         MDxFinalize( &mdDataSum );
  10076.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10077.     
  10078.     MDxInit( &mdDataSum );
  10079.     MD4Translate( lpData, len, &mdDataSum );    
  10080.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10081.  
  10082.     return;
  10083. }
  10084.  
  10085.  
  10086. -------------- Include
  10087.  
  10088. #ifndef __windows_h__
  10089.         typedef unsigned long DWORD;
  10090.         #define STDCALL _stdcall
  10091. #endif
  10092.  
  10093. typedef struct 
  10094. {
  10095.     DWORD dwSum[4];
  10096. }MDxSum;
  10097.  
  10098. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  10099. void STDCALL MDxInit( MDxSum * );
  10100. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  10101. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  10102. const char * STDCALL MDxGetVersion();
  10103. void STDCALL MDxFinalize( MDxSum * );
  10104.  
  10105.  
  10106. #include "mdx.h"
  10107. #include <stdlib.h>
  10108. #include <stdio.h>
  10109. #include <string.h>
  10110.  
  10111. // READLEN % 64 must = 0
  10112. #define READLEN    1048576L // 2^20, 1MB
  10113.  
  10114. void DigestFile( char * );
  10115. void DigestString();
  10116.  
  10117. void main(int argc, char *argv[])
  10118. {
  10119.     printf("%s\n\n", MDxGetVersion());
  10120.  
  10121.     if( argc > 1 )
  10122.         DigestFile( argv[1] );
  10123.     else    
  10124.         DigestString();
  10125.  
  10126. }
  10127.  
  10128. /*
  10129.     I use the 'chunk' method for processing files not because of
  10130.     limitations of my dll, but think what would happen if you
  10131.     tried to load an entire cd image into memory.
  10132. */
  10133. void DigestFile( char *szFName )
  10134. {
  10135.     FILE *file;
  10136.     void *lpData;
  10137.     long flen, mlen;
  10138.     MDxSum mdDataSum;
  10139.     MDxSum md4DataSum;
  10140.  
  10141.     // the 64 is for padding purposes
  10142.     lpData = malloc( READLEN + 64 );
  10143.     
  10144.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  10145.  
  10146.     file = fopen( szFName, "rb" );
  10147.     if( file == NULL )
  10148.     {
  10149.         printf("ERROR: File not found.\n");
  10150.         return;
  10151.     }
  10152.     
  10153.     MDxInit( &mdDataSum );
  10154.     MDxInit( &md4DataSum );
  10155.     
  10156.     fseek( file, 0, SEEK_END );
  10157.     //Get the file length
  10158.     flen = mlen = ftell( file );
  10159.     fseek( file, 0, SEEK_SET );
  10160.     
  10161.     // When it takes a while to process a large file,
  10162.     // remember that for each chunk it has to run 
  10163.     // through the main translation loop 16384 times!
  10164.         
  10165.     printf("Processing %ld byte file: .", flen );
  10166.     
  10167.     while( flen > READLEN )
  10168.     {
  10169.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10170.         {
  10171.             printf("READ ERROR!\n");
  10172.             return;
  10173.         }
  10174.         MD5Translate( lpData, READLEN, &mdDataSum );
  10175.         MD4Translate( lpData, READLEN, &md4DataSum );
  10176.         flen -= READLEN;
  10177.         printf(".");
  10178.     }
  10179.  
  10180.     if (fread( lpData, 1, flen, file ) != flen)
  10181.     {
  10182.         printf("READ ERROR!\n");
  10183.         return;
  10184.     }
  10185.     // This is why I added the new argument to MDxPad
  10186.     // So we can pass the length of the data AND the
  10187.     // Total length of the message
  10188.     // Also it now returns the # of padding bytes added,
  10189.     // this is for files that are an exact multiple of the chunk
  10190.     // length. (Otherwise the padding isn't Translated)
  10191.     flen += MDxPad( lpData, flen, mlen );
  10192.     MD5Translate( lpData, flen, &mdDataSum );    
  10193.     MD4Translate( lpData, flen, &md4DataSum );
  10194.  
  10195.     // New step necessary because of the 'chunking' method
  10196.     MDxFinalize( &mdDataSum );
  10197.     MDxFinalize( &md4DataSum );
  10198.     
  10199.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10200.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10201.     fclose(file);
  10202.         
  10203. }
  10204.  
  10205. void DigestString()
  10206. {
  10207.     
  10208.     //For our demo purposes, no strings bigger than 1024 :)
  10209.     unsigned char lpData[1024] = "";
  10210.     long len = 0;
  10211.     MDxSum mdDataSum;
  10212.  
  10213.     printf("Enter the string to digest: ");
  10214.     scanf("%s", &lpData );
  10215.     len = strlen(lpData);
  10216.     
  10217.     // Have to do this before the Padding...well...it's best anyway;)
  10218.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10219.     
  10220.     // For the strings, we're gonna pad and digest the string
  10221.     // in one pass.
  10222.     MDxInit( &mdDataSum );
  10223.     MDxPad( lpData, len, len );
  10224.     
  10225.     MD5Translate( lpData, len, &mdDataSum );
  10226.         // New step necessary because of the 'chunking' method
  10227.         MDxFinalize( &mdDataSum );
  10228.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10229.     
  10230.     MDxInit( &mdDataSum );
  10231.     MD4Translate( lpData, len, &mdDataSum );    
  10232.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10233.  
  10234.     return;
  10235. }
  10236.  
  10237.  
  10238. -------------- Include
  10239.  
  10240. #ifndef __windows_h__
  10241.         typedef unsigned long DWORD;
  10242.         #define STDCALL _stdcall
  10243. #endif
  10244.  
  10245. typedef struct 
  10246. {
  10247.     DWORD dwSum[4];
  10248. }MDxSum;
  10249.  
  10250. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  10251. void STDCALL MDxInit( MDxSum * );
  10252. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  10253. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  10254. const char * STDCALL MDxGetVersion();
  10255. void STDCALL MDxFinalize( MDxSum * );
  10256.  
  10257.  
  10258. #include "mdx.h"
  10259. #include <stdlib.h>
  10260. #include <stdio.h>
  10261. #include <string.h>
  10262.  
  10263. // READLEN % 64 must = 0
  10264. #define READLEN    1048576L // 2^20, 1MB
  10265.  
  10266. void DigestFile( char * );
  10267. void DigestString();
  10268.  
  10269. void main(int argc, char *argv[])
  10270. {
  10271.     printf("%s\n\n", MDxGetVersion());
  10272.  
  10273.     if( argc > 1 )
  10274.         DigestFile( argv[1] );
  10275.     else    
  10276.         DigestString();
  10277.  
  10278. }
  10279.  
  10280. /*
  10281.     I use the 'chunk' method for processing files not because of
  10282.     limitations of my dll, but think what would happen if you
  10283.     tried to load an entire cd image into memory.
  10284. */
  10285. void DigestFile( char *szFName )
  10286. {
  10287.     FILE *file;
  10288.     void *lpData;
  10289.     long flen, mlen;
  10290.     MDxSum mdDataSum;
  10291.     MDxSum md4DataSum;
  10292.  
  10293.     // the 64 is for padding purposes
  10294.     lpData = malloc( READLEN + 64 );
  10295.     
  10296.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  10297.  
  10298.     file = fopen( szFName, "rb" );
  10299.     if( file == NULL )
  10300.     {
  10301.         printf("ERROR: File not found.\n");
  10302.         return;
  10303.     }
  10304.     
  10305.     MDxInit( &mdDataSum );
  10306.     MDxInit( &md4DataSum );
  10307.     
  10308.     fseek( file, 0, SEEK_END );
  10309.     //Get the file length
  10310.     flen = mlen = ftell( file );
  10311.     fseek( file, 0, SEEK_SET );
  10312.     
  10313.     // When it takes a while to process a large file,
  10314.     // remember that for each chunk it has to run 
  10315.     // through the main translation loop 16384 times!
  10316.         
  10317.     printf("Processing %ld byte file: .", flen );
  10318.     
  10319.     while( flen > READLEN )
  10320.     {
  10321.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10322.         {
  10323.             printf("READ ERROR!\n");
  10324.             return;
  10325.         }
  10326.         MD5Translate( lpData, READLEN, &mdDataSum );
  10327.         MD4Translate( lpData, READLEN, &md4DataSum );
  10328.         flen -= READLEN;
  10329.         printf(".");
  10330.     }
  10331.  
  10332.     if (fread( lpData, 1, flen, file ) != flen)
  10333.     {
  10334.         printf("READ ERROR!\n");
  10335.         return;
  10336.     }
  10337.     // This is why I added the new argument to MDxPad
  10338.     // So we can pass the length of the data AND the
  10339.     // Total length of the message
  10340.     // Also it now returns the # of padding bytes added,
  10341.     // this is for files that are an exact multiple of the chunk
  10342.     // length. (Otherwise the padding isn't Translated)
  10343.     flen += MDxPad( lpData, flen, mlen );
  10344.     MD5Translate( lpData, flen, &mdDataSum );    
  10345.     MD4Translate( lpData, flen, &md4DataSum );
  10346.  
  10347.     // New step necessary because of the 'chunking' method
  10348.     MDxFinalize( &mdDataSum );
  10349.     MDxFinalize( &md4DataSum );
  10350.     
  10351.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10352.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10353.     fclose(file);
  10354.         
  10355. }
  10356.  
  10357. void DigestString()
  10358. {
  10359.     
  10360.     //For our demo purposes, no strings bigger than 1024 :)
  10361.     unsigned char lpData[1024] = "";
  10362.     long len = 0;
  10363.     MDxSum mdDataSum;
  10364.  
  10365.     printf("Enter the string to digest: ");
  10366.     scanf("%s", &lpData );
  10367.     len = strlen(lpData);
  10368.     
  10369.     // Have to do this before the Padding...well...it's best anyway;)
  10370.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10371.     
  10372.     // For the strings, we're gonna pad and digest the string
  10373.     // in one pass.
  10374.     MDxInit( &mdDataSum );
  10375.     MDxPad( lpData, len, len );
  10376.     
  10377.     MD5Translate( lpData, len, &mdDataSum );
  10378.         // New step necessary because of the 'chunking' method
  10379.         MDxFinalize( &mdDataSum );
  10380.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10381.     
  10382.     MDxInit( &mdDataSum );
  10383.     MD4Translate( lpData, len, &mdDataSum );    
  10384.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10385.  
  10386.     return;
  10387. }
  10388.  
  10389.  
  10390. -------------- Include
  10391.  
  10392. #ifndef __windows_h__
  10393.         typedef unsigned long DWORD;
  10394.         #define STDCALL _stdcall
  10395. #endif
  10396.  
  10397. typedef struct 
  10398. {
  10399.     DWORD dwSum[4];
  10400. }MDxSum;
  10401.  
  10402. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  10403. void STDCALL MDxInit( MDxSum * );
  10404. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  10405. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  10406. const char * STDCALL MDxGetVersion();
  10407. void STDCALL MDxFinalize( MDxSum * );
  10408.  
  10409. #include "mdx.h"
  10410. #include <stdlib.h>
  10411. #include <stdio.h>
  10412. #include <string.h>
  10413.  
  10414. // READLEN % 64 must = 0
  10415. #define READLEN    1048576L // 2^20, 1MB
  10416.  
  10417. void DigestFile( char * );
  10418. void DigestString();
  10419.  
  10420. void main(int argc, char *argv[])
  10421. {
  10422.     printf("%s\n\n", MDxGetVersion());
  10423.  
  10424.     if( argc > 1 )
  10425.         DigestFile( argv[1] );
  10426.     else    
  10427.         DigestString();
  10428.  
  10429. }
  10430.  
  10431. /*
  10432.     I use the 'chunk' method for processing files not because of
  10433.     limitations of my dll, but think what would happen if you
  10434.     tried to load an entire cd image into memory.
  10435. */
  10436. void DigestFile( char *szFName )
  10437. {
  10438.     FILE *file;
  10439.     void *lpData;
  10440.     long flen, mlen;
  10441.     MDxSum mdDataSum;
  10442.     MDxSum md4DataSum;
  10443.  
  10444.     // the 64 is for padding purposes
  10445.     lpData = malloc( READLEN + 64 );
  10446.     
  10447.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  10448.  
  10449.     file = fopen( szFName, "rb" );
  10450.     if( file == NULL )
  10451.     {
  10452.         printf("ERROR: File not found.\n");
  10453.         return;
  10454.     }
  10455.     
  10456.     MDxInit( &mdDataSum );
  10457.     MDxInit( &md4DataSum );
  10458.     
  10459.     fseek( file, 0, SEEK_END );
  10460.     //Get the file length
  10461.     flen = mlen = ftell( file );
  10462.     fseek( file, 0, SEEK_SET );
  10463.     
  10464.     // When it takes a while to process a large file,
  10465.     // remember that for each chunk it has to run 
  10466.     // through the main translation loop 16384 times!
  10467.         
  10468.     printf("Processing %ld byte file: .", flen );
  10469.     
  10470.     while( flen > READLEN )
  10471.     {
  10472.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10473.         {
  10474.             printf("READ ERROR!\n");
  10475.             return;
  10476.         }
  10477.         MD5Translate( lpData, READLEN, &mdDataSum );
  10478.         MD4Translate( lpData, READLEN, &md4DataSum );
  10479.         flen -= READLEN;
  10480.         printf(".");
  10481.     }
  10482.  
  10483.     if (fread( lpData, 1, flen, file ) != flen)
  10484.     {
  10485.         printf("READ ERROR!\n");
  10486.         return;
  10487.     }
  10488.     // This is why I added the new argument to MDxPad
  10489.     // So we can pass the length of the data AND the
  10490.     // Total length of the message
  10491.     // Also it now returns the # of padding bytes added,
  10492.     // this is for files that are an exact multiple of the chunk
  10493.     // length. (Otherwise the padding isn't Translated)
  10494.     flen += MDxPad( lpData, flen, mlen );
  10495.     MD5Translate( lpData, flen, &mdDataSum );    
  10496.     MD4Translate( lpData, flen, &md4DataSum );
  10497.  
  10498.     // New step necessary because of the 'chunking' method
  10499.     MDxFinalize( &mdDataSum );
  10500.     MDxFinalize( &md4DataSum );
  10501.     
  10502.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10503.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10504.     fclose(file);
  10505.         
  10506. }
  10507.  
  10508. void DigestString()
  10509. {
  10510.     
  10511.     //For our demo purposes, no strings bigger than 1024 :)
  10512.     unsigned char lpData[1024] = "";
  10513.     long len = 0;
  10514.     MDxSum mdDataSum;
  10515.  
  10516.     printf("Enter the string to digest: ");
  10517.     scanf("%s", &lpData );
  10518.     len = strlen(lpData);
  10519.     
  10520.     // Have to do this before the Padding...well...it's best anyway;)
  10521.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10522.     
  10523.     // For the strings, we're gonna pad and digest the string
  10524.     // in one pass.
  10525.     MDxInit( &mdDataSum );
  10526.     MDxPad( lpData, len, len );
  10527.     
  10528.     MD5Translate( lpData, len, &mdDataSum );
  10529.         // New step necessary because of the 'chunking' method
  10530.         MDxFinalize( &mdDataSum );
  10531.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10532.     
  10533.     MDxInit( &mdDataSum );
  10534.     MD4Translate( lpData, len, &mdDataSum );    
  10535.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10536.  
  10537.     return;
  10538. }
  10539.  
  10540.  
  10541. -------------- Include
  10542.  
  10543. #ifndef __windows_h__
  10544.         typedef unsigned long DWORD;
  10545.         #define STDCALL _stdcall
  10546. #endif
  10547.  
  10548. typedef struct 
  10549. {
  10550.     DWORD dwSum[4];
  10551. }MDxSum;
  10552.  
  10553. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  10554. void STDCALL MDxInit( MDxSum * );
  10555. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  10556. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  10557. const char * STDCALL MDxGetVersion();
  10558. void STDCALL MDxFinalize( MDxSum * );
  10559.  
  10560.  
  10561.  
  10562. #include "mdx.h"
  10563. #include <stdlib.h>
  10564. #include <stdio.h>
  10565. #include <string.h>
  10566.  
  10567. // READLEN % 64 must = 0
  10568. #define READLEN    1048576L // 2^20, 1MB
  10569.  
  10570. void DigestFile( char * );
  10571. void DigestString();
  10572.  
  10573. void main(int argc, char *argv[])
  10574. {
  10575.     printf("%s\n\n", MDxGetVersion());
  10576.  
  10577.     if( argc > 1 )
  10578.         DigestFile( argv[1] );
  10579.     else    
  10580.         DigestString();
  10581.  
  10582. }
  10583.  
  10584. /*
  10585.     I use the 'chunk' method for processing files not because of
  10586.     limitations of my dll, but think what would happen if you
  10587.     tried to load an entire cd image into memory.
  10588. */
  10589. void DigestFile( char *szFName )
  10590. {
  10591.     FILE *file;
  10592.     void *lpData;
  10593.     long flen, mlen;
  10594.     MDxSum mdDataSum;
  10595.     MDxSum md4DataSum;
  10596.  
  10597.     // the 64 is for padding purposes
  10598.     lpData = malloc( READLEN + 64 );
  10599.     
  10600.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  10601.  
  10602.     file = fopen( szFName, "rb" );
  10603.     if( file == NULL )
  10604.     {
  10605.         printf("ERROR: File not found.\n");
  10606.         return;
  10607.     }
  10608.     
  10609.     MDxInit( &mdDataSum );
  10610.     MDxInit( &md4DataSum );
  10611.     
  10612.     fseek( file, 0, SEEK_END );
  10613.     //Get the file length
  10614.     flen = mlen = ftell( file );
  10615.     fseek( file, 0, SEEK_SET );
  10616.     
  10617.     // When it takes a while to process a large file,
  10618.     // remember that for each chunk it has to run 
  10619.     // through the main translation loop 16384 times!
  10620.         
  10621.     printf("Processing %ld byte file: .", flen );
  10622.     
  10623.     while( flen > READLEN )
  10624.     {
  10625.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10626.         {
  10627.             printf("READ ERROR!\n");
  10628.             return;
  10629.         }
  10630.         MD5Translate( lpData, READLEN, &mdDataSum );
  10631.         MD4Translate( lpData, READLEN, &md4DataSum );
  10632.         flen -= READLEN;
  10633.         printf(".");
  10634.     }
  10635.  
  10636.     if (fread( lpData, 1, flen, file ) != flen)
  10637.     {
  10638.         printf("READ ERROR!\n");
  10639.         return;
  10640.     }
  10641.     // This is why I added the new argument to MDxPad
  10642.     // So we can pass the length of the data AND the
  10643.     // Total length of the message
  10644.     // Also it now returns the # of padding bytes added,
  10645.     // this is for files that are an exact multiple of the chunk
  10646.     // length. (Otherwise the padding isn't Translated)
  10647.     flen += MDxPad( lpData, flen, mlen );
  10648.     MD5Translate( lpData, flen, &mdDataSum );    
  10649.     MD4Translate( lpData, flen, &md4DataSum );
  10650.  
  10651.     // New step necessary because of the 'chunking' method
  10652.     MDxFinalize( &mdDataSum );
  10653.     MDxFinalize( &md4DataSum );
  10654.     
  10655.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10656.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10657.     fclose(file);
  10658.         
  10659. }
  10660.  
  10661. void DigestString()
  10662. {
  10663.     
  10664.     //For our demo purposes, no strings bigger than 1024 :)
  10665.     unsigned char lpData[1024] = "";
  10666.     long len = 0;
  10667.     MDxSum mdDataSum;
  10668.  
  10669.     printf("Enter the string to digest: ");
  10670.     scanf("%s", &lpData );
  10671.     len = strlen(lpData);
  10672.     
  10673.     // Have to do this before the Padding...well...it's best anyway;)
  10674.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10675.     
  10676.     // For the strings, we're gonna pad and digest the string
  10677.     // in one pass.
  10678.     MDxInit( &mdDataSum );
  10679.     MDxPad( lpData, len, len );
  10680.     
  10681.     MD5Translate( lpData, len, &mdDataSum );
  10682.         // New step necessary because of the 'chunking' method
  10683.         MDxFinalize( &mdDataSum );
  10684.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10685.     
  10686.     MDxInit( &mdDataSum );
  10687.     MD4Translate( lpData, len, &mdDataSum );    
  10688.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10689.  
  10690.     return;
  10691. }
  10692.  
  10693.  
  10694. -------------- Include
  10695.  
  10696. #ifndef __windows_h__
  10697.         typedef unsigned long DWORD;
  10698.         #define STDCALL _stdcall
  10699. #endif
  10700.  
  10701. typedef struct 
  10702. {
  10703.     DWORD dwSum[4];
  10704. }MDxSum;
  10705.  
  10706. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  10707. void STDCALL MDxInit( MDxSum * );
  10708. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  10709. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  10710. const char * STDCALL MDxGetVersion();
  10711. void STDCALL MDxFinalize( MDxSum * );
  10712.  
  10713.  
  10714.  
  10715. #include "mdx.h"
  10716. #include <stdlib.h>
  10717. #include <stdio.h>
  10718. #include <string.h>
  10719.  
  10720. // READLEN % 64 must = 0
  10721. #define READLEN    1048576L // 2^20, 1MB
  10722.  
  10723. void DigestFile( char * );
  10724. void DigestString();
  10725.  
  10726. void main(int argc, char *argv[])
  10727. {
  10728.     printf("%s\n\n", MDxGetVersion());
  10729.  
  10730.     if( argc > 1 )
  10731.         DigestFile( argv[1] );
  10732.     else    
  10733.         DigestString();
  10734.  
  10735. }
  10736.  
  10737. /*
  10738.     I use the 'chunk' method for processing files not because of
  10739.     limitations of my dll, but think what would happen if you
  10740.     tried to load an entire cd image into memory.
  10741. */
  10742. void DigestFile( char *szFName )
  10743. {
  10744.     FILE *file;
  10745.     void *lpData;
  10746.     long flen, mlen;
  10747.     MDxSum mdDataSum;
  10748.     MDxSum md4DataSum;
  10749.  
  10750.     // the 64 is for padding purposes
  10751.     lpData = malloc( READLEN + 64 );
  10752.     
  10753.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  10754.  
  10755.     file = fopen( szFName, "rb" );
  10756.     if( file == NULL )
  10757.     {
  10758.         printf("ERROR: File not found.\n");
  10759.         return;
  10760.     }
  10761.     
  10762.     MDxInit( &mdDataSum );
  10763.     MDxInit( &md4DataSum );
  10764.     
  10765.     fseek( file, 0, SEEK_END );
  10766.     //Get the file length
  10767.     flen = mlen = ftell( file );
  10768.     fseek( file, 0, SEEK_SET );
  10769.     
  10770.     // When it takes a while to process a large file,
  10771.     // remember that for each chunk it has to run 
  10772.     // through the main translation loop 16384 times!
  10773.         
  10774.     printf("Processing %ld byte file: .", flen );
  10775.     
  10776.     while( flen > READLEN )
  10777.     {
  10778.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10779.         {
  10780.             printf("READ ERROR!\n");
  10781.             return;
  10782.         }
  10783.         MD5Translate( lpData, READLEN, &mdDataSum );
  10784.         MD4Translate( lpData, READLEN, &md4DataSum );
  10785.         flen -= READLEN;
  10786.         printf(".");
  10787.     }
  10788.  
  10789.     if (fread( lpData, 1, flen, file ) != flen)
  10790.     {
  10791.         printf("READ ERROR!\n");
  10792.         return;
  10793.     }
  10794.     // This is why I added the new argument to MDxPad
  10795.     // So we can pass the length of the data AND the
  10796.     // Total length of the message
  10797.     // Also it now returns the # of padding bytes added,
  10798.     // this is for files that are an exact multiple of the chunk
  10799.     // length. (Otherwise the padding isn't Translated)
  10800.     flen += MDxPad( lpData, flen, mlen );
  10801.     MD5Translate( lpData, flen, &mdDataSum );    
  10802.     MD4Translate( lpData, flen, &md4DataSum );
  10803.  
  10804.     // New step necessary because of the 'chunking' method
  10805.     MDxFinalize( &mdDataSum );
  10806.     MDxFinalize( &md4DataSum );
  10807.     
  10808.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10809.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10810.     fclose(file);
  10811.         
  10812. }
  10813.  
  10814. void DigestString()
  10815. {
  10816.     
  10817.     //For our demo purposes, no strings bigger than 1024 :)
  10818.     unsigned char lpData[1024] = "";
  10819.     long len = 0;
  10820.     MDxSum mdDataSum;
  10821.  
  10822.     printf("Enter the string to digest: ");
  10823.     scanf("%s", &lpData );
  10824.     len = strlen(lpData);
  10825.     
  10826.     // Have to do this before the Padding...well...it's best anyway;)
  10827.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10828.     
  10829.     // For the strings, we're gonna pad and digest the string
  10830.     // in one pass.
  10831.     MDxInit( &mdDataSum );
  10832.     MDxPad( lpData, len, len );
  10833.     
  10834.     MD5Translate( lpData, len, &mdDataSum );
  10835.         // New step necessary because of the 'chunking' method
  10836.         MDxFinalize( &mdDataSum );
  10837.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10838.     
  10839.     MDxInit( &mdDataSum );
  10840.     MD4Translate( lpData, len, &mdDataSum );    
  10841.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10842.  
  10843.     return;
  10844. }
  10845.  
  10846.  
  10847. -------------- Include
  10848.  
  10849. #ifndef __windows_h__
  10850.         typedef unsigned long DWORD;
  10851.         #define STDCALL _stdcall
  10852. #endif
  10853.  
  10854. typedef struct 
  10855. {
  10856.     DWORD dwSum[4];
  10857. }MDxSum;
  10858.  
  10859. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  10860. void STDCALL MDxInit( MDxSum * );
  10861. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  10862. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  10863. const char * STDCALL MDxGetVersion();
  10864. void STDCALL MDxFinalize( MDxSum * );
  10865.  
  10866.  
  10867.  
  10868. #include "mdx.h"
  10869. #include <stdlib.h>
  10870. #include <stdio.h>
  10871. #include <string.h>
  10872.  
  10873. // READLEN % 64 must = 0
  10874. #define READLEN    1048576L // 2^20, 1MB
  10875.  
  10876. void DigestFile( char * );
  10877. void DigestString();
  10878.  
  10879. void main(int argc, char *argv[])
  10880. {
  10881.     printf("%s\n\n", MDxGetVersion());
  10882.  
  10883.     if( argc > 1 )
  10884.         DigestFile( argv[1] );
  10885.     else    
  10886.         DigestString();
  10887.  
  10888. }
  10889.  
  10890. /*
  10891.     I use the 'chunk' method for processing files not because of
  10892.     limitations of my dll, but think what would happen if you
  10893.     tried to load an entire cd image into memory.
  10894. */
  10895. void DigestFile( char *szFName )
  10896. {
  10897.     FILE *file;
  10898.     void *lpData;
  10899.     long flen, mlen;
  10900.     MDxSum mdDataSum;
  10901.     MDxSum md4DataSum;
  10902.  
  10903.     // the 64 is for padding purposes
  10904.     lpData = malloc( READLEN + 64 );
  10905.     
  10906.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  10907.  
  10908.     file = fopen( szFName, "rb" );
  10909.     if( file == NULL )
  10910.     {
  10911.         printf("ERROR: File not found.\n");
  10912.         return;
  10913.     }
  10914.     
  10915.     MDxInit( &mdDataSum );
  10916.     MDxInit( &md4DataSum );
  10917.     
  10918.     fseek( file, 0, SEEK_END );
  10919.     //Get the file length
  10920.     flen = mlen = ftell( file );
  10921.     fseek( file, 0, SEEK_SET );
  10922.     
  10923.     // When it takes a while to process a large file,
  10924.     // remember that for each chunk it has to run 
  10925.     // through the main translation loop 16384 times!
  10926.         
  10927.     printf("Processing %ld byte file: .", flen );
  10928.     
  10929.     while( flen > READLEN )
  10930.     {
  10931.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  10932.         {
  10933.             printf("READ ERROR!\n");
  10934.             return;
  10935.         }
  10936.         MD5Translate( lpData, READLEN, &mdDataSum );
  10937.         MD4Translate( lpData, READLEN, &md4DataSum );
  10938.         flen -= READLEN;
  10939.         printf(".");
  10940.     }
  10941.  
  10942.     if (fread( lpData, 1, flen, file ) != flen)
  10943.     {
  10944.         printf("READ ERROR!\n");
  10945.         return;
  10946.     }
  10947.     // This is why I added the new argument to MDxPad
  10948.     // So we can pass the length of the data AND the
  10949.     // Total length of the message
  10950.     // Also it now returns the # of padding bytes added,
  10951.     // this is for files that are an exact multiple of the chunk
  10952.     // length. (Otherwise the padding isn't Translated)
  10953.     flen += MDxPad( lpData, flen, mlen );
  10954.     MD5Translate( lpData, flen, &mdDataSum );    
  10955.     MD4Translate( lpData, flen, &md4DataSum );
  10956.  
  10957.     // New step necessary because of the 'chunking' method
  10958.     MDxFinalize( &mdDataSum );
  10959.     MDxFinalize( &md4DataSum );
  10960.     
  10961.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  10962.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10963.     fclose(file);
  10964.         
  10965. }
  10966.  
  10967. void DigestString()
  10968. {
  10969.     
  10970.     //For our demo purposes, no strings bigger than 1024 :)
  10971.     unsigned char lpData[1024] = "";
  10972.     long len = 0;
  10973.     MDxSum mdDataSum;
  10974.  
  10975.     printf("Enter the string to digest: ");
  10976.     scanf("%s", &lpData );
  10977.     len = strlen(lpData);
  10978.     
  10979.     // Have to do this before the Padding...well...it's best anyway;)
  10980.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  10981.     
  10982.     // For the strings, we're gonna pad and digest the string
  10983.     // in one pass.
  10984.     MDxInit( &mdDataSum );
  10985.     MDxPad( lpData, len, len );
  10986.     
  10987.     MD5Translate( lpData, len, &mdDataSum );
  10988.         // New step necessary because of the 'chunking' method
  10989.         MDxFinalize( &mdDataSum );
  10990.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10991.     
  10992.     MDxInit( &mdDataSum );
  10993.     MD4Translate( lpData, len, &mdDataSum );    
  10994.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  10995.  
  10996.     return;
  10997. }
  10998.  
  10999.  
  11000. -------------- Include
  11001.  
  11002. #ifndef __windows_h__
  11003.         typedef unsigned long DWORD;
  11004.         #define STDCALL _stdcall
  11005. #endif
  11006.  
  11007. typedef struct 
  11008. {
  11009.     DWORD dwSum[4];
  11010. }MDxSum;
  11011.  
  11012. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11013. void STDCALL MDxInit( MDxSum * );
  11014. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11015. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11016. const char * STDCALL MDxGetVersion();
  11017. void STDCALL MDxFinalize( MDxSum * );
  11018.  
  11019.  
  11020.  
  11021. #include "mdx.h"
  11022. #include <stdlib.h>
  11023. #include <stdio.h>
  11024. #include <string.h>
  11025.  
  11026. // READLEN % 64 must = 0
  11027. #define READLEN    1048576L // 2^20, 1MB
  11028.  
  11029. void DigestFile( char * );
  11030. void DigestString();
  11031.  
  11032. void main(int argc, char *argv[])
  11033. {
  11034.     printf("%s\n\n", MDxGetVersion());
  11035.  
  11036.     if( argc > 1 )
  11037.         DigestFile( argv[1] );
  11038.     else    
  11039.         DigestString();
  11040.  
  11041. }
  11042.  
  11043. /*
  11044.     I use the 'chunk' method for processing files not because of
  11045.     limitations of my dll, but think what would happen if you
  11046.     tried to load an entire cd image into memory.
  11047. */
  11048. void DigestFile( char *szFName )
  11049. {
  11050.     FILE *file;
  11051.     void *lpData;
  11052.     long flen, mlen;
  11053.     MDxSum mdDataSum;
  11054.     MDxSum md4DataSum;
  11055.  
  11056.     // the 64 is for padding purposes
  11057.     lpData = malloc( READLEN + 64 );
  11058.     
  11059.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11060.  
  11061.     file = fopen( szFName, "rb" );
  11062.     if( file == NULL )
  11063.     {
  11064.         printf("ERROR: File not found.\n");
  11065.         return;
  11066.     }
  11067.     
  11068.     MDxInit( &mdDataSum );
  11069.     MDxInit( &md4DataSum );
  11070.     
  11071.     fseek( file, 0, SEEK_END );
  11072.     //Get the file length
  11073.     flen = mlen = ftell( file );
  11074.     fseek( file, 0, SEEK_SET );
  11075.     
  11076.     // When it takes a while to process a large file,
  11077.     // remember that for each chunk it has to run 
  11078.     // through the main translation loop 16384 times!
  11079.         
  11080.     printf("Processing %ld byte file: .", flen );
  11081.     
  11082.     while( flen > READLEN )
  11083.     {
  11084.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  11085.         {
  11086.             printf("READ ERROR!\n");
  11087.             return;
  11088.         }
  11089.         MD5Translate( lpData, READLEN, &mdDataSum );
  11090.         MD4Translate( lpData, READLEN, &md4DataSum );
  11091.         flen -= READLEN;
  11092.         printf(".");
  11093.     }
  11094.  
  11095.     if (fread( lpData, 1, flen, file ) != flen)
  11096.     {
  11097.         printf("READ ERROR!\n");
  11098.         return;
  11099.     }
  11100.     // This is why I added the new argument to MDxPad
  11101.     // So we can pass the length of the data AND the
  11102.     // Total length of the message
  11103.     // Also it now returns the # of padding bytes added,
  11104.     // this is for files that are an exact multiple of the chunk
  11105.     // length. (Otherwise the padding isn't Translated)
  11106.     flen += MDxPad( lpData, flen, mlen );
  11107.     MD5Translate( lpData, flen, &mdDataSum );    
  11108.     MD4Translate( lpData, flen, &md4DataSum );
  11109.  
  11110.     // New step necessary because of the 'chunking' method
  11111.     MDxFinalize( &mdDataSum );
  11112.     MDxFinalize( &md4DataSum );
  11113.     
  11114.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  11115.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11116.     fclose(file);
  11117.         
  11118. }
  11119.  
  11120. void DigestString()
  11121. {
  11122.     
  11123.     //For our demo purposes, no strings bigger than 1024 :)
  11124.     unsigned char lpData[1024] = "";
  11125.     long len = 0;
  11126.     MDxSum mdDataSum;
  11127.  
  11128.     printf("Enter the string to digest: ");
  11129.     scanf("%s", &lpData );
  11130.     len = strlen(lpData);
  11131.     
  11132.     // Have to do this before the Padding...well...it's best anyway;)
  11133.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  11134.     
  11135.     // For the strings, we're gonna pad and digest the string
  11136.     // in one pass.
  11137.     MDxInit( &mdDataSum );
  11138.     MDxPad( lpData, len, len );
  11139.     
  11140.     MD5Translate( lpData, len, &mdDataSum );
  11141.         // New step necessary because of the 'chunking' method
  11142.         MDxFinalize( &mdDataSum );
  11143.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11144.     
  11145.     MDxInit( &mdDataSum );
  11146.     MD4Translate( lpData, len, &mdDataSum );    
  11147.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11148.  
  11149.     return;
  11150. }
  11151.  
  11152.  
  11153. -------------- Include
  11154.  
  11155. #ifndef __windows_h__
  11156.         typedef unsigned long DWORD;
  11157.         #define STDCALL _stdcall
  11158. #endif
  11159.  
  11160. typedef struct 
  11161. {
  11162.     DWORD dwSum[4];
  11163. }MDxSum;
  11164.  
  11165. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11166. void STDCALL MDxInit( MDxSum * );
  11167. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11168. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11169. const char * STDCALL MDxGetVersion();
  11170. void STDCALL MDxFinalize( MDxSum * );
  11171.  
  11172.  
  11173.  
  11174.  
  11175. #include "mdx.h"
  11176. #include <stdlib.h>
  11177. #include <stdio.h>
  11178. #include <string.h>
  11179.  
  11180. // READLEN % 64 must = 0
  11181. #define READLEN    1048576L // 2^20, 1MB
  11182.  
  11183. void DigestFile( char * );
  11184. void DigestString();
  11185.  
  11186. void main(int argc, char *argv[])
  11187. {
  11188.     printf("%s\n\n", MDxGetVersion());
  11189.  
  11190.     if( argc > 1 )
  11191.         DigestFile( argv[1] );
  11192.     else    
  11193.         DigestString();
  11194.  
  11195. }
  11196.  
  11197. /*
  11198.     I use the 'chunk' method for processing files not because of
  11199.     limitations of my dll, but think what would happen if you
  11200.     tried to load an entire cd image into memory.
  11201. */
  11202. void DigestFile( char *szFName )
  11203. {
  11204.     FILE *file;
  11205.     void *lpData;
  11206.     long flen, mlen;
  11207.     MDxSum mdDataSum;
  11208.     MDxSum md4DataSum;
  11209.  
  11210.     // the 64 is for padding purposes
  11211.     lpData = malloc( READLEN + 64 );
  11212.     
  11213.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11214.  
  11215.     file = fopen( szFName, "rb" );
  11216.     if( file == NULL )
  11217.     {
  11218.         printf("ERROR: File not found.\n");
  11219.         return;
  11220.     }
  11221.     
  11222.     MDxInit( &mdDataSum );
  11223.     MDxInit( &md4DataSum );
  11224.     
  11225.     fseek( file, 0, SEEK_END );
  11226.     //Get the file length
  11227.     flen = mlen = ftell( file );
  11228.     fseek( file, 0, SEEK_SET );
  11229.     
  11230.     // When it takes a while to process a large file,
  11231.     // remember that for each chunk it has to run 
  11232.     // through the main translation loop 16384 times!
  11233.         
  11234.     printf("Processing %ld byte file: .", flen );
  11235.     
  11236.     while( flen > READLEN )
  11237.     {
  11238.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  11239.         {
  11240.             printf("READ ERROR!\n");
  11241.             return;
  11242.         }
  11243.         MD5Translate( lpData, READLEN, &mdDataSum );
  11244.         MD4Translate( lpData, READLEN, &md4DataSum );
  11245.         flen -= READLEN;
  11246.         printf(".");
  11247.     }
  11248.  
  11249.     if (fread( lpData, 1, flen, file ) != flen)
  11250.     {
  11251.         printf("READ ERROR!\n");
  11252.         return;
  11253.     }
  11254.     // This is why I added the new argument to MDxPad
  11255.     // So we can pass the length of the data AND the
  11256.     // Total length of the message
  11257.     // Also it now returns the # of padding bytes added,
  11258.     // this is for files that are an exact multiple of the chunk
  11259.     // length. (Otherwise the padding isn't Translated)
  11260.     flen += MDxPad( lpData, flen, mlen );
  11261.     MD5Translate( lpData, flen, &mdDataSum );    
  11262.     MD4Translate( lpData, flen, &md4DataSum );
  11263.  
  11264.     // New step necessary because of the 'chunking' method
  11265.     MDxFinalize( &mdDataSum );
  11266.     MDxFinalize( &md4DataSum );
  11267.     
  11268.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  11269.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11270.     fclose(file);
  11271.         
  11272. }
  11273.  
  11274. void DigestString()
  11275. {
  11276.     
  11277.     //For our demo purposes, no strings bigger than 1024 :)
  11278.     unsigned char lpData[1024] = "";
  11279.     long len = 0;
  11280.     MDxSum mdDataSum;
  11281.  
  11282.     printf("Enter the string to digest: ");
  11283.     scanf("%s", &lpData );
  11284.     len = strlen(lpData);
  11285.     
  11286.     // Have to do this before the Padding...well...it's best anyway;)
  11287.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  11288.     
  11289.     // For the strings, we're gonna pad and digest the string
  11290.     // in one pass.
  11291.     MDxInit( &mdDataSum );
  11292.     MDxPad( lpData, len, len );
  11293.     
  11294.     MD5Translate( lpData, len, &mdDataSum );
  11295.         // New step necessary because of the 'chunking' method
  11296.         MDxFinalize( &mdDataSum );
  11297.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11298.     
  11299.     MDxInit( &mdDataSum );
  11300.     MD4Translate( lpData, len, &mdDataSum );    
  11301.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11302.  
  11303.     return;
  11304. }
  11305.  
  11306.  
  11307. -------------- Include
  11308.  
  11309. #ifndef __windows_h__
  11310.         typedef unsigned long DWORD;
  11311.         #define STDCALL _stdcall
  11312. #endif
  11313.  
  11314. typedef struct 
  11315. {
  11316.     DWORD dwSum[4];
  11317. }MDxSum;
  11318.  
  11319. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11320. void STDCALL MDxInit( MDxSum * );
  11321. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11322. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11323. const char * STDCALL MDxGetVersion();
  11324. void STDCALL MDxFinalize( MDxSum * );
  11325.  
  11326.  
  11327.  
  11328.  
  11329. #include "mdx.h"
  11330. #include <stdlib.h>
  11331. #include <stdio.h>
  11332. #include <string.h>
  11333.  
  11334. // READLEN % 64 must = 0
  11335. #define READLEN    1048576L // 2^20, 1MB
  11336.  
  11337. void DigestFile( char * );
  11338. void DigestString();
  11339.  
  11340. void main(int argc, char *argv[])
  11341. {
  11342.     printf("%s\n\n", MDxGetVersion());
  11343.  
  11344.     if( argc > 1 )
  11345.         DigestFile( argv[1] );
  11346.     else    
  11347.         DigestString();
  11348.  
  11349. }
  11350.  
  11351. /*
  11352.     I use the 'chunk' method for processing files not because of
  11353.     limitations of my dll, but think what would happen if you
  11354.     tried to load an entire cd image into memory.
  11355. */
  11356. void DigestFile( char *szFName )
  11357. {
  11358.     FILE *file;
  11359.     void *lpData;
  11360.     long flen, mlen;
  11361.     MDxSum mdDataSum;
  11362.     MDxSum md4DataSum;
  11363.  
  11364.     // the 64 is for padding purposes
  11365.     lpData = malloc( READLEN + 64 );
  11366.     
  11367.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11368.  
  11369.     file = fopen( szFName, "rb" );
  11370.     if( file == NULL )
  11371.     {
  11372.         printf("ERROR: File not found.\n");
  11373.         return;
  11374.     }
  11375.     
  11376.     MDxInit( &mdDataSum );
  11377.     MDxInit( &md4DataSum );
  11378.     
  11379.     fseek( file, 0, SEEK_END );
  11380.     //Get the file length
  11381.     flen = mlen = ftell( file );
  11382.     fseek( file, 0, SEEK_SET );
  11383.     
  11384.     // When it takes a while to process a large file,
  11385.     // remember that for each chunk it has to run 
  11386.     // through the main translation loop 16384 times!
  11387.         
  11388.     printf("Processing %ld byte file: .", flen );
  11389.     
  11390.     while( flen > READLEN )
  11391.     {
  11392.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  11393.         {
  11394.             printf("READ ERROR!\n");
  11395.             return;
  11396.         }
  11397.         MD5Translate( lpData, READLEN, &mdDataSum );
  11398.         MD4Translate( lpData, READLEN, &md4DataSum );
  11399.         flen -= READLEN;
  11400.         printf(".");
  11401.     }
  11402.  
  11403.     if (fread( lpData, 1, flen, file ) != flen)
  11404.     {
  11405.         printf("READ ERROR!\n");
  11406.         return;
  11407.     }
  11408.     // This is why I added the new argument to MDxPad
  11409.     // So we can pass the length of the data AND the
  11410.     // Total length of the message
  11411.     // Also it now returns the # of padding bytes added,
  11412.     // this is for files that are an exact multiple of the chunk
  11413.     // length. (Otherwise the padding isn't Translated)
  11414.     flen += MDxPad( lpData, flen, mlen );
  11415.     MD5Translate( lpData, flen, &mdDataSum );    
  11416.     MD4Translate( lpData, flen, &md4DataSum );
  11417.  
  11418.     // New step necessary because of the 'chunking' method
  11419.     MDxFinalize( &mdDataSum );
  11420.     MDxFinalize( &md4DataSum );
  11421.     
  11422.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  11423.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11424.     fclose(file);
  11425.         
  11426. }
  11427.  
  11428. void DigestString()
  11429. {
  11430.     
  11431.     //For our demo purposes, no strings bigger than 1024 :)
  11432.     unsigned char lpData[1024] = "";
  11433.     long len = 0;
  11434.     MDxSum mdDataSum;
  11435.  
  11436.     printf("Enter the string to digest: ");
  11437.     scanf("%s", &lpData );
  11438.     len = strlen(lpData);
  11439.     
  11440.     // Have to do this before the Padding...well...it's best anyway;)
  11441.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  11442.     
  11443.     // For the strings, we're gonna pad and digest the string
  11444.     // in one pass.
  11445.     MDxInit( &mdDataSum );
  11446.     MDxPad( lpData, len, len );
  11447.     
  11448.     MD5Translate( lpData, len, &mdDataSum );
  11449.         // New step necessary because of the 'chunking' method
  11450.         MDxFinalize( &mdDataSum );
  11451.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11452.     
  11453.     MDxInit( &mdDataSum );
  11454.     MD4Translate( lpData, len, &mdDataSum );    
  11455.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11456.  
  11457.     return;
  11458. }
  11459.  
  11460.  
  11461. -------------- Include
  11462.  
  11463. #ifndef __windows_h__
  11464.         typedef unsigned long DWORD;
  11465.         #define STDCALL _stdcall
  11466. #endif
  11467.  
  11468. typedef struct 
  11469. {
  11470.     DWORD dwSum[4];
  11471. }MDxSum;
  11472.  
  11473. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11474. void STDCALL MDxInit( MDxSum * );
  11475. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11476. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11477. const char * STDCALL MDxGetVersion();
  11478. void STDCALL MDxFinalize( MDxSum * );
  11479.  
  11480.  
  11481.  
  11482.  
  11483. #include "mdx.h"
  11484. #include <stdlib.h>
  11485. #include <stdio.h>
  11486. #include <string.h>
  11487.  
  11488. // READLEN % 64 must = 0
  11489. #define READLEN    1048576L // 2^20, 1MB
  11490.  
  11491. void DigestFile( char * );
  11492. void DigestString();
  11493.  
  11494. void main(int argc, char *argv[])
  11495. {
  11496.     printf("%s\n\n", MDxGetVersion());
  11497.  
  11498.     if( argc > 1 )
  11499.         DigestFile( argv[1] );
  11500.     else    
  11501.         DigestString();
  11502.  
  11503. }
  11504.  
  11505. /*
  11506.     I use the 'chunk' method for processing files not because of
  11507.     limitations of my dll, but think what would happen if you
  11508.     tried to load an entire cd image into memory.
  11509. */
  11510. void DigestFile( char *szFName )
  11511. {
  11512.     FILE *file;
  11513.     void *lpData;
  11514.     long flen, mlen;
  11515.     MDxSum mdDataSum;
  11516.     MDxSum md4DataSum;
  11517.  
  11518.     // the 64 is for padding purposes
  11519.     lpData = malloc( READLEN + 64 );
  11520.     
  11521.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11522.  
  11523.     file = fopen( szFName, "rb" );
  11524.     if( file == NULL )
  11525.     {
  11526.         printf("ERROR: File not found.\n");
  11527.         return;
  11528.     }
  11529.     
  11530.     MDxInit( &mdDataSum );
  11531.     MDxInit( &md4DataSum );
  11532.     
  11533.     fseek( file, 0, SEEK_END );
  11534.     //Get the file length
  11535.     flen = mlen = ftell( file );
  11536.     fseek( file, 0, SEEK_SET );
  11537.     
  11538.     // When it takes a while to process a large file,
  11539.     // remember that for each chunk it has to run 
  11540.     // through the main translation loop 16384 times!
  11541.         
  11542.     printf("Processing %ld byte file: .", flen );
  11543.     
  11544.     while( flen > READLEN )
  11545.     {
  11546.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  11547.         {
  11548.             printf("READ ERROR!\n");
  11549.             return;
  11550.         }
  11551.         MD5Translate( lpData, READLEN, &mdDataSum );
  11552.         MD4Translate( lpData, READLEN, &md4DataSum );
  11553.         flen -= READLEN;
  11554.         printf(".");
  11555.     }
  11556.  
  11557.     if (fread( lpData, 1, flen, file ) != flen)
  11558.     {
  11559.         printf("READ ERROR!\n");
  11560.         return;
  11561.     }
  11562.     // This is why I added the new argument to MDxPad
  11563.     // So we can pass the length of the data AND the
  11564.     // Total length of the message
  11565.     // Also it now returns the # of padding bytes added,
  11566.     // this is for files that are an exact multiple of the chunk
  11567.     // length. (Otherwise the padding isn't Translated)
  11568.     flen += MDxPad( lpData, flen, mlen );
  11569.     MD5Translate( lpData, flen, &mdDataSum );    
  11570.     MD4Translate( lpData, flen, &md4DataSum );
  11571.  
  11572.     // New step necessary because of the 'chunking' method
  11573.     MDxFinalize( &mdDataSum );
  11574.     MDxFinalize( &md4DataSum );
  11575.     
  11576.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  11577.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11578.     fclose(file);
  11579.         
  11580. }
  11581.  
  11582. void DigestString()
  11583. {
  11584.     
  11585.     //For our demo purposes, no strings bigger than 1024 :)
  11586.     unsigned char lpData[1024] = "";
  11587.     long len = 0;
  11588.     MDxSum mdDataSum;
  11589.  
  11590.     printf("Enter the string to digest: ");
  11591.     scanf("%s", &lpData );
  11592.     len = strlen(lpData);
  11593.     
  11594.     // Have to do this before the Padding...well...it's best anyway;)
  11595.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  11596.     
  11597.     // For the strings, we're gonna pad and digest the string
  11598.     // in one pass.
  11599.     MDxInit( &mdDataSum );
  11600.     MDxPad( lpData, len, len );
  11601.     
  11602.     MD5Translate( lpData, len, &mdDataSum );
  11603.         // New step necessary because of the 'chunking' method
  11604.         MDxFinalize( &mdDataSum );
  11605.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11606.     
  11607.     MDxInit( &mdDataSum );
  11608.     MD4Translate( lpData, len, &mdDataSum );    
  11609.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11610.  
  11611.     return;
  11612. }
  11613.  
  11614.  
  11615. -------------- Include
  11616.  
  11617. #ifndef __windows_h__
  11618.         typedef unsigned long DWORD;
  11619.         #define STDCALL _stdcall
  11620. #endif
  11621.  
  11622. typedef struct 
  11623. {
  11624.     DWORD dwSum[4];
  11625. }MDxSum;
  11626.  
  11627. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11628. void STDCALL MDxInit( MDxSum * );
  11629. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11630. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11631. const char * STDCALL MDxGetVersion();
  11632. void STDCALL MDxFinalize( MDxSum * );
  11633.  
  11634.  
  11635.  
  11636. #include "mdx.h"
  11637. #include <stdlib.h>
  11638. #include <stdio.h>
  11639. #include <string.h>
  11640.  
  11641. // READLEN % 64 must = 0
  11642. #define READLEN    1048576L // 2^20, 1MB
  11643.  
  11644. void DigestFile( char * );
  11645. void DigestString();
  11646.  
  11647. void main(int argc, char *argv[])
  11648. {
  11649.     printf("%s\n\n", MDxGetVersion());
  11650.  
  11651.     if( argc > 1 )
  11652.         DigestFile( argv[1] );
  11653.     else    
  11654.         DigestString();
  11655.  
  11656. }
  11657.  
  11658. /*
  11659.     I use the 'chunk' method for processing files not because of
  11660.     limitations of my dll, but think what would happen if you
  11661.     tried to load an entire cd image into memory.
  11662. */
  11663. void DigestFile( char *szFName )
  11664. {
  11665.     FILE *file;
  11666.     void *lpData;
  11667.     long flen, mlen;
  11668.     MDxSum mdDataSum;
  11669.     MDxSum md4DataSum;
  11670.  
  11671.     // the 64 is for padding purposes
  11672.     lpData = malloc( READLEN + 64 );
  11673.     
  11674.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11675.  
  11676.     file = fopen( szFName, "rb" );
  11677.     if( file == NULL )
  11678.     {
  11679.         printf("ERROR: File not found.\n");
  11680.         return;
  11681.     }
  11682.     
  11683.     MDxInit( &mdDataSum );
  11684.     MDxInit( &md4DataSum );
  11685.     
  11686.     fseek( file, 0, SEEK_END );
  11687.     //Get the file length
  11688.     flen = mlen = ftell( file );
  11689.     fseek( file, 0, SEEK_SET );
  11690.     
  11691.     // When it takes a while to process a large file,
  11692.     // remember that for each chunk it has to run 
  11693.     // through the main translation loop 16384 times!
  11694.         
  11695.     printf("Processing %ld byte file: .", flen );
  11696.     
  11697.     while( flen > READLEN )
  11698.     {
  11699.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  11700.         {
  11701.             printf("READ ERROR!\n");
  11702.             return;
  11703.         }
  11704.         MD5Translate( lpData, READLEN, &mdDataSum );
  11705.         MD4Translate( lpData, READLEN, &md4DataSum );
  11706.         flen -= READLEN;
  11707.         printf(".");
  11708.     }
  11709.  
  11710.     if (fread( lpData, 1, flen, file ) != flen)
  11711.     {
  11712.         printf("READ ERROR!\n");
  11713.         return;
  11714.     }
  11715.     // This is why I added the new argument to MDxPad
  11716.     // So we can pass the length of the data AND the
  11717.     // Total length of the message
  11718.     // Also it now returns the # of padding bytes added,
  11719.     // this is for files that are an exact multiple of the chunk
  11720.     // length. (Otherwise the padding isn't Translated)
  11721.     flen += MDxPad( lpData, flen, mlen );
  11722.     MD5Translate( lpData, flen, &mdDataSum );    
  11723.     MD4Translate( lpData, flen, &md4DataSum );
  11724.  
  11725.     // New step necessary because of the 'chunking' method
  11726.     MDxFinalize( &mdDataSum );
  11727.     MDxFinalize( &md4DataSum );
  11728.     
  11729.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  11730.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11731.     fclose(file);
  11732.         
  11733. }
  11734.  
  11735. void DigestString()
  11736. {
  11737.     
  11738.     //For our demo purposes, no strings bigger than 1024 :)
  11739.     unsigned char lpData[1024] = "";
  11740.     long len = 0;
  11741.     MDxSum mdDataSum;
  11742.  
  11743.     printf("Enter the string to digest: ");
  11744.     scanf("%s", &lpData );
  11745.     len = strlen(lpData);
  11746.     
  11747.     // Have to do this before the Padding...well...it's best anyway;)
  11748.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  11749.     
  11750.     // For the strings, we're gonna pad and digest the string
  11751.     // in one pass.
  11752.     MDxInit( &mdDataSum );
  11753.     MDxPad( lpData, len, len );
  11754.     
  11755.     MD5Translate( lpData, len, &mdDataSum );
  11756.         // New step necessary because of the 'chunking' method
  11757.         MDxFinalize( &mdDataSum );
  11758.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11759.     
  11760.     MDxInit( &mdDataSum );
  11761.     MD4Translate( lpData, len, &mdDataSum );    
  11762.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11763.  
  11764.     return;
  11765. }
  11766.  
  11767.  
  11768. -------------- Include
  11769.  
  11770. #ifndef __windows_h__
  11771.         typedef unsigned long DWORD;
  11772.         #define STDCALL _stdcall
  11773. #endif
  11774.  
  11775. typedef struct 
  11776. {
  11777.     DWORD dwSum[4];
  11778. }MDxSum;
  11779.  
  11780. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11781. void STDCALL MDxInit( MDxSum * );
  11782. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11783. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11784. const char * STDCALL MDxGetVersion();
  11785. void STDCALL MDxFinalize( MDxSum * );
  11786.  
  11787.  
  11788.  
  11789. #include "mdx.h"
  11790. #include <stdlib.h>
  11791. #include <stdio.h>
  11792. #include <string.h>
  11793.  
  11794. // READLEN % 64 must = 0
  11795. #define READLEN    1048576L // 2^20, 1MB
  11796.  
  11797. void DigestFile( char * );
  11798. void DigestString();
  11799.  
  11800. void main(int argc, char *argv[])
  11801. {
  11802.     printf("%s\n\n", MDxGetVersion());
  11803.  
  11804.     if( argc > 1 )
  11805.         DigestFile( argv[1] );
  11806.     else    
  11807.         DigestString();
  11808.  
  11809. }
  11810.  
  11811. /*
  11812.     I use the 'chunk' method for processing files not because of
  11813.     limitations of my dll, but think what would happen if you
  11814.     tried to load an entire cd image into memory.
  11815. */
  11816. void DigestFile( char *szFName )
  11817. {
  11818.     FILE *file;
  11819.     void *lpData;
  11820.     long flen, mlen;
  11821.     MDxSum mdDataSum;
  11822.     MDxSum md4DataSum;
  11823.  
  11824.     // the 64 is for padding purposes
  11825.     lpData = malloc( READLEN + 64 );
  11826.     
  11827.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11828.  
  11829.     file = fopen( szFName, "rb" );
  11830.     if( file == NULL )
  11831.     {
  11832.         printf("ERROR: File not found.\n");
  11833.         return;
  11834.     }
  11835.     
  11836.     MDxInit( &mdDataSum );
  11837.     MDxInit( &md4DataSum );
  11838.     
  11839.     fseek( file, 0, SEEK_END );
  11840.     //Get the file length
  11841.     flen = mlen = ftell( file );
  11842.     fseek( file, 0, SEEK_SET );
  11843.     
  11844.     // When it takes a while to process a large file,
  11845.     // remember that for each chunk it has to run 
  11846.     // through the main translation loop 16384 times!
  11847.         
  11848.     printf("Processing %ld byte file: .", flen );
  11849.     
  11850.     while( flen > READLEN )
  11851.     {
  11852.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  11853.         {
  11854.             printf("READ ERROR!\n");
  11855.             return;
  11856.         }
  11857.         MD5Translate( lpData, READLEN, &mdDataSum );
  11858.         MD4Translate( lpData, READLEN, &md4DataSum );
  11859.         flen -= READLEN;
  11860.         printf(".");
  11861.     }
  11862.  
  11863.     if (fread( lpData, 1, flen, file ) != flen)
  11864.     {
  11865.         printf("READ ERROR!\n");
  11866.         return;
  11867.     }
  11868.     // This is why I added the new argument to MDxPad
  11869.     // So we can pass the length of the data AND the
  11870.     // Total length of the message
  11871.     // Also it now returns the # of padding bytes added,
  11872.     // this is for files that are an exact multiple of the chunk
  11873.     // length. (Otherwise the padding isn't Translated)
  11874.     flen += MDxPad( lpData, flen, mlen );
  11875.     MD5Translate( lpData, flen, &mdDataSum );    
  11876.     MD4Translate( lpData, flen, &md4DataSum );
  11877.  
  11878.     // New step necessary because of the 'chunking' method
  11879.     MDxFinalize( &mdDataSum );
  11880.     MDxFinalize( &md4DataSum );
  11881.     
  11882.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  11883.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11884.     fclose(file);
  11885.         
  11886. }
  11887.  
  11888. void DigestString()
  11889. {
  11890.     
  11891.     //For our demo purposes, no strings bigger than 1024 :)
  11892.     unsigned char lpData[1024] = "";
  11893.     long len = 0;
  11894.     MDxSum mdDataSum;
  11895.  
  11896.     printf("Enter the string to digest: ");
  11897.     scanf("%s", &lpData );
  11898.     len = strlen(lpData);
  11899.     
  11900.     // Have to do this before the Padding...well...it's best anyway;)
  11901.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  11902.     
  11903.     // For the strings, we're gonna pad and digest the string
  11904.     // in one pass.
  11905.     MDxInit( &mdDataSum );
  11906.     MDxPad( lpData, len, len );
  11907.     
  11908.     MD5Translate( lpData, len, &mdDataSum );
  11909.         // New step necessary because of the 'chunking' method
  11910.         MDxFinalize( &mdDataSum );
  11911.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11912.     
  11913.     MDxInit( &mdDataSum );
  11914.     MD4Translate( lpData, len, &mdDataSum );    
  11915.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  11916.  
  11917.     return;
  11918. }
  11919.  
  11920.  
  11921. -------------- Include
  11922.  
  11923. #ifndef __windows_h__
  11924.         typedef unsigned long DWORD;
  11925.         #define STDCALL _stdcall
  11926. #endif
  11927.  
  11928. typedef struct 
  11929. {
  11930.     DWORD dwSum[4];
  11931. }MDxSum;
  11932.  
  11933. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  11934. void STDCALL MDxInit( MDxSum * );
  11935. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  11936. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  11937. const char * STDCALL MDxGetVersion();
  11938. void STDCALL MDxFinalize( MDxSum * );
  11939.  
  11940.  
  11941.  
  11942.  
  11943. #include "mdx.h"
  11944. #include <stdlib.h>
  11945. #include <stdio.h>
  11946. #include <string.h>
  11947.  
  11948. // READLEN % 64 must = 0
  11949. #define READLEN    1048576L // 2^20, 1MB
  11950.  
  11951. void DigestFile( char * );
  11952. void DigestString();
  11953.  
  11954. void main(int argc, char *argv[])
  11955. {
  11956.     printf("%s\n\n", MDxGetVersion());
  11957.  
  11958.     if( argc > 1 )
  11959.         DigestFile( argv[1] );
  11960.     else    
  11961.         DigestString();
  11962.  
  11963. }
  11964.  
  11965. /*
  11966.     I use the 'chunk' method for processing files not because of
  11967.     limitations of my dll, but think what would happen if you
  11968.     tried to load an entire cd image into memory.
  11969. */
  11970. void DigestFile( char *szFName )
  11971. {
  11972.     FILE *file;
  11973.     void *lpData;
  11974.     long flen, mlen;
  11975.     MDxSum mdDataSum;
  11976.     MDxSum md4DataSum;
  11977.  
  11978.     // the 64 is for padding purposes
  11979.     lpData = malloc( READLEN + 64 );
  11980.     
  11981.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  11982.  
  11983.     file = fopen( szFName, "rb" );
  11984.     if( file == NULL )
  11985.     {
  11986.         printf("ERROR: File not found.\n");
  11987.         return;
  11988.     }
  11989.     
  11990.     MDxInit( &mdDataSum );
  11991.     MDxInit( &md4DataSum );
  11992.     
  11993.     fseek( file, 0, SEEK_END );
  11994.     //Get the file length
  11995.     flen = mlen = ftell( file );
  11996.     fseek( file, 0, SEEK_SET );
  11997.     
  11998.     // When it takes a while to process a large file,
  11999.     // remember that for each chunk it has to run 
  12000.     // through the main translation loop 16384 times!
  12001.         
  12002.     printf("Processing %ld byte file: .", flen );
  12003.     
  12004.     while( flen > READLEN )
  12005.     {
  12006.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12007.         {
  12008.             printf("READ ERROR!\n");
  12009.             return;
  12010.         }
  12011.         MD5Translate( lpData, READLEN, &mdDataSum );
  12012.         MD4Translate( lpData, READLEN, &md4DataSum );
  12013.         flen -= READLEN;
  12014.         printf(".");
  12015.     }
  12016.  
  12017.     if (fread( lpData, 1, flen, file ) != flen)
  12018.     {
  12019.         printf("READ ERROR!\n");
  12020.         return;
  12021.     }
  12022.     // This is why I added the new argument to MDxPad
  12023.     // So we can pass the length of the data AND the
  12024.     // Total length of the message
  12025.     // Also it now returns the # of padding bytes added,
  12026.     // this is for files that are an exact multiple of the chunk
  12027.     // length. (Otherwise the padding isn't Translated)
  12028.     flen += MDxPad( lpData, flen, mlen );
  12029.     MD5Translate( lpData, flen, &mdDataSum );    
  12030.     MD4Translate( lpData, flen, &md4DataSum );
  12031.  
  12032.     // New step necessary because of the 'chunking' method
  12033.     MDxFinalize( &mdDataSum );
  12034.     MDxFinalize( &md4DataSum );
  12035.     
  12036.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12037.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12038.     fclose(file);
  12039.         
  12040. }
  12041.  
  12042. void DigestString()
  12043. {
  12044.     
  12045.     //For our demo purposes, no strings bigger than 1024 :)
  12046.     unsigned char lpData[1024] = "";
  12047.     long len = 0;
  12048.     MDxSum mdDataSum;
  12049.  
  12050.     printf("Enter the string to digest: ");
  12051.     scanf("%s", &lpData );
  12052.     len = strlen(lpData);
  12053.     
  12054.     // Have to do this before the Padding...well...it's best anyway;)
  12055.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12056.     
  12057.     // For the strings, we're gonna pad and digest the string
  12058.     // in one pass.
  12059.     MDxInit( &mdDataSum );
  12060.     MDxPad( lpData, len, len );
  12061.     
  12062.     MD5Translate( lpData, len, &mdDataSum );
  12063.         // New step necessary because of the 'chunking' method
  12064.         MDxFinalize( &mdDataSum );
  12065.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12066.     
  12067.     MDxInit( &mdDataSum );
  12068.     MD4Translate( lpData, len, &mdDataSum );    
  12069.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12070.  
  12071.     return;
  12072. }
  12073.  
  12074.  
  12075. -------------- Include
  12076.  
  12077. #ifndef __windows_h__
  12078.         typedef unsigned long DWORD;
  12079.         #define STDCALL _stdcall
  12080. #endif
  12081.  
  12082. typedef struct 
  12083. {
  12084.     DWORD dwSum[4];
  12085. }MDxSum;
  12086.  
  12087. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  12088. void STDCALL MDxInit( MDxSum * );
  12089. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  12090. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  12091. const char * STDCALL MDxGetVersion();
  12092. void STDCALL MDxFinalize( MDxSum * );
  12093.  
  12094.  
  12095.  
  12096.  
  12097. #include "mdx.h"
  12098. #include <stdlib.h>
  12099. #include <stdio.h>
  12100. #include <string.h>
  12101.  
  12102. // READLEN % 64 must = 0
  12103. #define READLEN    1048576L // 2^20, 1MB
  12104.  
  12105. void DigestFile( char * );
  12106. void DigestString();
  12107.  
  12108. void main(int argc, char *argv[])
  12109. {
  12110.     printf("%s\n\n", MDxGetVersion());
  12111.  
  12112.     if( argc > 1 )
  12113.         DigestFile( argv[1] );
  12114.     else    
  12115.         DigestString();
  12116.  
  12117. }
  12118.  
  12119. /*
  12120.     I use the 'chunk' method for processing files not because of
  12121.     limitations of my dll, but think what would happen if you
  12122.     tried to load an entire cd image into memory.
  12123. */
  12124. void DigestFile( char *szFName )
  12125. {
  12126.     FILE *file;
  12127.     void *lpData;
  12128.     long flen, mlen;
  12129.     MDxSum mdDataSum;
  12130.     MDxSum md4DataSum;
  12131.  
  12132.     // the 64 is for padding purposes
  12133.     lpData = malloc( READLEN + 64 );
  12134.     
  12135.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  12136.  
  12137.     file = fopen( szFName, "rb" );
  12138.     if( file == NULL )
  12139.     {
  12140.         printf("ERROR: File not found.\n");
  12141.         return;
  12142.     }
  12143.     
  12144.     MDxInit( &mdDataSum );
  12145.     MDxInit( &md4DataSum );
  12146.     
  12147.     fseek( file, 0, SEEK_END );
  12148.     //Get the file length
  12149.     flen = mlen = ftell( file );
  12150.     fseek( file, 0, SEEK_SET );
  12151.     
  12152.     // When it takes a while to process a large file,
  12153.     // remember that for each chunk it has to run 
  12154.     // through the main translation loop 16384 times!
  12155.         
  12156.     printf("Processing %ld byte file: .", flen );
  12157.     
  12158.     while( flen > READLEN )
  12159.     {
  12160.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12161.         {
  12162.             printf("READ ERROR!\n");
  12163.             return;
  12164.         }
  12165.         MD5Translate( lpData, READLEN, &mdDataSum );
  12166.         MD4Translate( lpData, READLEN, &md4DataSum );
  12167.         flen -= READLEN;
  12168.         printf(".");
  12169.     }
  12170.  
  12171.     if (fread( lpData, 1, flen, file ) != flen)
  12172.     {
  12173.         printf("READ ERROR!\n");
  12174.         return;
  12175.     }
  12176.     // This is why I added the new argument to MDxPad
  12177.     // So we can pass the length of the data AND the
  12178.     // Total length of the message
  12179.     // Also it now returns the # of padding bytes added,
  12180.     // this is for files that are an exact multiple of the chunk
  12181.     // length. (Otherwise the padding isn't Translated)
  12182.     flen += MDxPad( lpData, flen, mlen );
  12183.     MD5Translate( lpData, flen, &mdDataSum );    
  12184.     MD4Translate( lpData, flen, &md4DataSum );
  12185.  
  12186.     // New step necessary because of the 'chunking' method
  12187.     MDxFinalize( &mdDataSum );
  12188.     MDxFinalize( &md4DataSum );
  12189.     
  12190.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12191.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12192.     fclose(file);
  12193.         
  12194. }
  12195.  
  12196. void DigestString()
  12197. {
  12198.     
  12199.     //For our demo purposes, no strings bigger than 1024 :)
  12200.     unsigned char lpData[1024] = "";
  12201.     long len = 0;
  12202.     MDxSum mdDataSum;
  12203.  
  12204.     printf("Enter the string to digest: ");
  12205.     scanf("%s", &lpData );
  12206.     len = strlen(lpData);
  12207.     
  12208.     // Have to do this before the Padding...well...it's best anyway;)
  12209.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12210.     
  12211.     // For the strings, we're gonna pad and digest the string
  12212.     // in one pass.
  12213.     MDxInit( &mdDataSum );
  12214.     MDxPad( lpData, len, len );
  12215.     
  12216.     MD5Translate( lpData, len, &mdDataSum );
  12217.         // New step necessary because of the 'chunking' method
  12218.         MDxFinalize( &mdDataSum );
  12219.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12220.     
  12221.     MDxInit( &mdDataSum );
  12222.     MD4Translate( lpData, len, &mdDataSum );    
  12223.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12224.  
  12225.     return;
  12226. }
  12227.  
  12228.  
  12229. -------------- Include
  12230.  
  12231. #ifndef __windows_h__
  12232.         typedef unsigned long DWORD;
  12233.         #define STDCALL _stdcall
  12234. #endif
  12235.  
  12236. typedef struct 
  12237. {
  12238.     DWORD dwSum[4];
  12239. }MDxSum;
  12240.  
  12241. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  12242. void STDCALL MDxInit( MDxSum * );
  12243. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  12244. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  12245. const char * STDCALL MDxGetVersion();
  12246. void STDCALL MDxFinalize( MDxSum * );
  12247.  
  12248.  
  12249.  
  12250.  
  12251. #include "mdx.h"
  12252. #include <stdlib.h>
  12253. #include <stdio.h>
  12254. #include <string.h>
  12255.  
  12256. // READLEN % 64 must = 0
  12257. #define READLEN    1048576L // 2^20, 1MB
  12258.  
  12259. void DigestFile( char * );
  12260. void DigestString();
  12261.  
  12262. void main(int argc, char *argv[])
  12263. {
  12264.     printf("%s\n\n", MDxGetVersion());
  12265.  
  12266.     if( argc > 1 )
  12267.         DigestFile( argv[1] );
  12268.     else    
  12269.         DigestString();
  12270.  
  12271. }
  12272.  
  12273. /*
  12274.     I use the 'chunk' method for processing files not because of
  12275.     limitations of my dll, but think what would happen if you
  12276.     tried to load an entire cd image into memory.
  12277. */
  12278. void DigestFile( char *szFName )
  12279. {
  12280.     FILE *file;
  12281.     void *lpData;
  12282.     long flen, mlen;
  12283.     MDxSum mdDataSum;
  12284.     MDxSum md4DataSum;
  12285.  
  12286.     // the 64 is for padding purposes
  12287.     lpData = malloc( READLEN + 64 );
  12288.     
  12289.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  12290.  
  12291.     file = fopen( szFName, "rb" );
  12292.     if( file == NULL )
  12293.     {
  12294.         printf("ERROR: File not found.\n");
  12295.         return;
  12296.     }
  12297.     
  12298.     MDxInit( &mdDataSum );
  12299.     MDxInit( &md4DataSum );
  12300.     
  12301.     fseek( file, 0, SEEK_END );
  12302.     //Get the file length
  12303.     flen = mlen = ftell( file );
  12304.     fseek( file, 0, SEEK_SET );
  12305.     
  12306.     // When it takes a while to process a large file,
  12307.     // remember that for each chunk it has to run 
  12308.     // through the main translation loop 16384 times!
  12309.         
  12310.     printf("Processing %ld byte file: .", flen );
  12311.     
  12312.     while( flen > READLEN )
  12313.     {
  12314.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12315.         {
  12316.             printf("READ ERROR!\n");
  12317.             return;
  12318.         }
  12319.         MD5Translate( lpData, READLEN, &mdDataSum );
  12320.         MD4Translate( lpData, READLEN, &md4DataSum );
  12321.         flen -= READLEN;
  12322.         printf(".");
  12323.     }
  12324.  
  12325.     if (fread( lpData, 1, flen, file ) != flen)
  12326.     {
  12327.         printf("READ ERROR!\n");
  12328.         return;
  12329.     }
  12330.     // This is why I added the new argument to MDxPad
  12331.     // So we can pass the length of the data AND the
  12332.     // Total length of the message
  12333.     // Also it now returns the # of padding bytes added,
  12334.     // this is for files that are an exact multiple of the chunk
  12335.     // length. (Otherwise the padding isn't Translated)
  12336.     flen += MDxPad( lpData, flen, mlen );
  12337.     MD5Translate( lpData, flen, &mdDataSum );    
  12338.     MD4Translate( lpData, flen, &md4DataSum );
  12339.  
  12340.     // New step necessary because of the 'chunking' method
  12341.     MDxFinalize( &mdDataSum );
  12342.     MDxFinalize( &md4DataSum );
  12343.     
  12344.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12345.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12346.     fclose(file);
  12347.         
  12348. }
  12349.  
  12350. void DigestString()
  12351. {
  12352.     
  12353.     //For our demo purposes, no strings bigger than 1024 :)
  12354.     unsigned char lpData[1024] = "";
  12355.     long len = 0;
  12356.     MDxSum mdDataSum;
  12357.  
  12358.     printf("Enter the string to digest: ");
  12359.     scanf("%s", &lpData );
  12360.     len = strlen(lpData);
  12361.     
  12362.     // Have to do this before the Padding...well...it's best anyway;)
  12363.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12364.     
  12365.     // For the strings, we're gonna pad and digest the string
  12366.     // in one pass.
  12367.     MDxInit( &mdDataSum );
  12368.     MDxPad( lpData, len, len );
  12369.     
  12370.     MD5Translate( lpData, len, &mdDataSum );
  12371.         // New step necessary because of the 'chunking' method
  12372.         MDxFinalize( &mdDataSum );
  12373.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12374.     
  12375.     MDxInit( &mdDataSum );
  12376.     MD4Translate( lpData, len, &mdDataSum );    
  12377.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12378.  
  12379.     return;
  12380. }
  12381.  
  12382.  
  12383. -------------- Include
  12384.  
  12385. #ifndef __windows_h__
  12386.         typedef unsigned long DWORD;
  12387.         #define STDCALL _stdcall
  12388. #endif
  12389.  
  12390. typedef struct 
  12391. {
  12392.     DWORD dwSum[4];
  12393. }MDxSum;
  12394.  
  12395. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  12396. void STDCALL MDxInit( MDxSum * );
  12397. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  12398. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  12399. const char * STDCALL MDxGetVersion();
  12400. void STDCALL MDxFinalize( MDxSum * );
  12401.  
  12402.  
  12403.  
  12404. #include "mdx.h"
  12405. #include <stdlib.h>
  12406. #include <stdio.h>
  12407. #include <string.h>
  12408.  
  12409. // READLEN % 64 must = 0
  12410. #define READLEN    1048576L // 2^20, 1MB
  12411.  
  12412. void DigestFile( char * );
  12413. void DigestString();
  12414.  
  12415. void main(int argc, char *argv[])
  12416. {
  12417.     printf("%s\n\n", MDxGetVersion());
  12418.  
  12419.     if( argc > 1 )
  12420.         DigestFile( argv[1] );
  12421.     else    
  12422.         DigestString();
  12423.  
  12424. }
  12425.  
  12426. /*
  12427.     I use the 'chunk' method for processing files not because of
  12428.     limitations of my dll, but think what would happen if you
  12429.     tried to load an entire cd image into memory.
  12430. */
  12431. void DigestFile( char *szFName )
  12432. {
  12433.     FILE *file;
  12434.     void *lpData;
  12435.     long flen, mlen;
  12436.     MDxSum mdDataSum;
  12437.     MDxSum md4DataSum;
  12438.  
  12439.     // the 64 is for padding purposes
  12440.     lpData = malloc( READLEN + 64 );
  12441.     
  12442.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  12443.  
  12444.     file = fopen( szFName, "rb" );
  12445.     if( file == NULL )
  12446.     {
  12447.         printf("ERROR: File not found.\n");
  12448.         return;
  12449.     }
  12450.     
  12451.     MDxInit( &mdDataSum );
  12452.     MDxInit( &md4DataSum );
  12453.     
  12454.     fseek( file, 0, SEEK_END );
  12455.     //Get the file length
  12456.     flen = mlen = ftell( file );
  12457.     fseek( file, 0, SEEK_SET );
  12458.     
  12459.     // When it takes a while to process a large file,
  12460.     // remember that for each chunk it has to run 
  12461.     // through the main translation loop 16384 times!
  12462.         
  12463.     printf("Processing %ld byte file: .", flen );
  12464.     
  12465.     while( flen > READLEN )
  12466.     {
  12467.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12468.         {
  12469.             printf("READ ERROR!\n");
  12470.             return;
  12471.         }
  12472.         MD5Translate( lpData, READLEN, &mdDataSum );
  12473.         MD4Translate( lpData, READLEN, &md4DataSum );
  12474.         flen -= READLEN;
  12475.         printf(".");
  12476.     }
  12477.  
  12478.     if (fread( lpData, 1, flen, file ) != flen)
  12479.     {
  12480.         printf("READ ERROR!\n");
  12481.         return;
  12482.     }
  12483.     // This is why I added the new argument to MDxPad
  12484.     // So we can pass the length of the data AND the
  12485.     // Total length of the message
  12486.     // Also it now returns the # of padding bytes added,
  12487.     // this is for files that are an exact multiple of the chunk
  12488.     // length. (Otherwise the padding isn't Translated)
  12489.     flen += MDxPad( lpData, flen, mlen );
  12490.     MD5Translate( lpData, flen, &mdDataSum );    
  12491.     MD4Translate( lpData, flen, &md4DataSum );
  12492.  
  12493.     // New step necessary because of the 'chunking' method
  12494.     MDxFinalize( &mdDataSum );
  12495.     MDxFinalize( &md4DataSum );
  12496.     
  12497.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12498.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12499.     fclose(file);
  12500.         
  12501. }
  12502.  
  12503. void DigestString()
  12504. {
  12505.     
  12506.     //For our demo purposes, no strings bigger than 1024 :)
  12507.     unsigned char lpData[1024] = "";
  12508.     long len = 0;
  12509.     MDxSum mdDataSum;
  12510.  
  12511.     printf("Enter the string to digest: ");
  12512.     scanf("%s", &lpData );
  12513.     len = strlen(lpData);
  12514.     
  12515.     // Have to do this before the Padding...well...it's best anyway;)
  12516.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12517.     
  12518.     // For the strings, we're gonna pad and digest the string
  12519.     // in one pass.
  12520.     MDxInit( &mdDataSum );
  12521.     MDxPad( lpData, len, len );
  12522.     
  12523.     MD5Translate( lpData, len, &mdDataSum );
  12524.         // New step necessary because of the 'chunking' method
  12525.         MDxFinalize( &mdDataSum );
  12526.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12527.     
  12528.     MDxInit( &mdDataSum );
  12529.     MD4Translate( lpData, len, &mdDataSum );    
  12530.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12531.  
  12532.     return;
  12533. }
  12534.  
  12535.  
  12536. -------------- Include
  12537.  
  12538. #ifndef __windows_h__
  12539.         typedef unsigned long DWORD;
  12540.         #define STDCALL _stdcall
  12541. #endif
  12542.  
  12543. typedef struct 
  12544. {
  12545.     DWORD dwSum[4];
  12546. }MDxSum;
  12547.  
  12548. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  12549. void STDCALL MDxInit( MDxSum * );
  12550. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  12551. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  12552. const char * STDCALL MDxGetVersion();
  12553. void STDCALL MDxFinalize( MDxSum * );
  12554.  
  12555.  
  12556.  
  12557. #include "mdx.h"
  12558. #include <stdlib.h>
  12559. #include <stdio.h>
  12560. #include <string.h>
  12561.  
  12562. // READLEN % 64 must = 0
  12563. #define READLEN    1048576L // 2^20, 1MB
  12564.  
  12565. void DigestFile( char * );
  12566. void DigestString();
  12567.  
  12568. void main(int argc, char *argv[])
  12569. {
  12570.     printf("%s\n\n", MDxGetVersion());
  12571.  
  12572.     if( argc > 1 )
  12573.         DigestFile( argv[1] );
  12574.     else    
  12575.         DigestString();
  12576.  
  12577. }
  12578.  
  12579. /*
  12580.     I use the 'chunk' method for processing files not because of
  12581.     limitations of my dll, but think what would happen if you
  12582.     tried to load an entire cd image into memory.
  12583. */
  12584. void DigestFile( char *szFName )
  12585. {
  12586.     FILE *file;
  12587.     void *lpData;
  12588.     long flen, mlen;
  12589.     MDxSum mdDataSum;
  12590.     MDxSum md4DataSum;
  12591.  
  12592.     // the 64 is for padding purposes
  12593.     lpData = malloc( READLEN + 64 );
  12594.     
  12595.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  12596.  
  12597.     file = fopen( szFName, "rb" );
  12598.     if( file == NULL )
  12599.     {
  12600.         printf("ERROR: File not found.\n");
  12601.         return;
  12602.     }
  12603.     
  12604.     MDxInit( &mdDataSum );
  12605.     MDxInit( &md4DataSum );
  12606.     
  12607.     fseek( file, 0, SEEK_END );
  12608.     //Get the file length
  12609.     flen = mlen = ftell( file );
  12610.     fseek( file, 0, SEEK_SET );
  12611.     
  12612.     // When it takes a while to process a large file,
  12613.     // remember that for each chunk it has to run 
  12614.     // through the main translation loop 16384 times!
  12615.         
  12616.     printf("Processing %ld byte file: .", flen );
  12617.     
  12618.     while( flen > READLEN )
  12619.     {
  12620.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12621.         {
  12622.             printf("READ ERROR!\n");
  12623.             return;
  12624.         }
  12625.         MD5Translate( lpData, READLEN, &mdDataSum );
  12626.         MD4Translate( lpData, READLEN, &md4DataSum );
  12627.         flen -= READLEN;
  12628.         printf(".");
  12629.     }
  12630.  
  12631.     if (fread( lpData, 1, flen, file ) != flen)
  12632.     {
  12633.         printf("READ ERROR!\n");
  12634.         return;
  12635.     }
  12636.     // This is why I added the new argument to MDxPad
  12637.     // So we can pass the length of the data AND the
  12638.     // Total length of the message
  12639.     // Also it now returns the # of padding bytes added,
  12640.     // this is for files that are an exact multiple of the chunk
  12641.     // length. (Otherwise the padding isn't Translated)
  12642.     flen += MDxPad( lpData, flen, mlen );
  12643.     MD5Translate( lpData, flen, &mdDataSum );    
  12644.     MD4Translate( lpData, flen, &md4DataSum );
  12645.  
  12646.     // New step necessary because of the 'chunking' method
  12647.     MDxFinalize( &mdDataSum );
  12648.     MDxFinalize( &md4DataSum );
  12649.     
  12650.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12651.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12652.     fclose(file);
  12653.         
  12654. }
  12655.  
  12656. void DigestString()
  12657. {
  12658.     
  12659.     //For our demo purposes, no strings bigger than 1024 :)
  12660.     unsigned char lpData[1024] = "";
  12661.     long len = 0;
  12662.     MDxSum mdDataSum;
  12663.  
  12664.     printf("Enter the string to digest: ");
  12665.     scanf("%s", &lpData );
  12666.     len = strlen(lpData);
  12667.     
  12668.     // Have to do this before the Padding...well...it's best anyway;)
  12669.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12670.     
  12671.     // For the strings, we're gonna pad and digest the string
  12672.     // in one pass.
  12673.     MDxInit( &mdDataSum );
  12674.     MDxPad( lpData, len, len );
  12675.     
  12676.     MD5Translate( lpData, len, &mdDataSum );
  12677.         // New step necessary because of the 'chunking' method
  12678.         MDxFinalize( &mdDataSum );
  12679.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12680.     
  12681.     MDxInit( &mdDataSum );
  12682.     MD4Translate( lpData, len, &mdDataSum );    
  12683.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12684.  
  12685.     return;
  12686. }
  12687.  
  12688.  
  12689. -------------- Include
  12690.  
  12691. #ifndef __windows_h__
  12692.         typedef unsigned long DWORD;
  12693.         #define STDCALL _stdcall
  12694. #endif
  12695.  
  12696. typedef struct 
  12697. {
  12698.     DWORD dwSum[4];
  12699. }MDxSum;
  12700.  
  12701. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  12702. void STDCALL MDxInit( MDxSum * );
  12703. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  12704. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  12705. const char * STDCALL MDxGetVersion();
  12706. void STDCALL MDxFinalize( MDxSum * );
  12707.  
  12708.  
  12709.  
  12710.  
  12711. #include "mdx.h"
  12712. #include <stdlib.h>
  12713. #include <stdio.h>
  12714. #include <string.h>
  12715.  
  12716. // READLEN % 64 must = 0
  12717. #define READLEN    1048576L // 2^20, 1MB
  12718.  
  12719. void DigestFile( char * );
  12720. void DigestString();
  12721.  
  12722. void main(int argc, char *argv[])
  12723. {
  12724.     printf("%s\n\n", MDxGetVersion());
  12725.  
  12726.     if( argc > 1 )
  12727.         DigestFile( argv[1] );
  12728.     else    
  12729.         DigestString();
  12730.  
  12731. }
  12732.  
  12733. /*
  12734.     I use the 'chunk' method for processing files not because of
  12735.     limitations of my dll, but think what would happen if you
  12736.     tried to load an entire cd image into memory.
  12737. */
  12738. void DigestFile( char *szFName )
  12739. {
  12740.     FILE *file;
  12741.     void *lpData;
  12742.     long flen, mlen;
  12743.     MDxSum mdDataSum;
  12744.     MDxSum md4DataSum;
  12745.  
  12746.     // the 64 is for padding purposes
  12747.     lpData = malloc( READLEN + 64 );
  12748.     
  12749.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  12750.  
  12751.     file = fopen( szFName, "rb" );
  12752.     if( file == NULL )
  12753.     {
  12754.         printf("ERROR: File not found.\n");
  12755.         return;
  12756.     }
  12757.     
  12758.     MDxInit( &mdDataSum );
  12759.     MDxInit( &md4DataSum );
  12760.     
  12761.     fseek( file, 0, SEEK_END );
  12762.     //Get the file length
  12763.     flen = mlen = ftell( file );
  12764.     fseek( file, 0, SEEK_SET );
  12765.     
  12766.     // When it takes a while to process a large file,
  12767.     // remember that for each chunk it has to run 
  12768.     // through the main translation loop 16384 times!
  12769.         
  12770.     printf("Processing %ld byte file: .", flen );
  12771.     
  12772.     while( flen > READLEN )
  12773.     {
  12774.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12775.         {
  12776.             printf("READ ERROR!\n");
  12777.             return;
  12778.         }
  12779.         MD5Translate( lpData, READLEN, &mdDataSum );
  12780.         MD4Translate( lpData, READLEN, &md4DataSum );
  12781.         flen -= READLEN;
  12782.         printf(".");
  12783.     }
  12784.  
  12785.     if (fread( lpData, 1, flen, file ) != flen)
  12786.     {
  12787.         printf("READ ERROR!\n");
  12788.         return;
  12789.     }
  12790.     // This is why I added the new argument to MDxPad
  12791.     // So we can pass the length of the data AND the
  12792.     // Total length of the message
  12793.     // Also it now returns the # of padding bytes added,
  12794.     // this is for files that are an exact multiple of the chunk
  12795.     // length. (Otherwise the padding isn't Translated)
  12796.     flen += MDxPad( lpData, flen, mlen );
  12797.     MD5Translate( lpData, flen, &mdDataSum );    
  12798.     MD4Translate( lpData, flen, &md4DataSum );
  12799.  
  12800.     // New step necessary because of the 'chunking' method
  12801.     MDxFinalize( &mdDataSum );
  12802.     MDxFinalize( &md4DataSum );
  12803.     
  12804.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12805.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12806.     fclose(file);
  12807.         
  12808. }
  12809.  
  12810. void DigestString()
  12811. {
  12812.     
  12813.     //For our demo purposes, no strings bigger than 1024 :)
  12814.     unsigned char lpData[1024] = "";
  12815.     long len = 0;
  12816.     MDxSum mdDataSum;
  12817.  
  12818.     printf("Enter the string to digest: ");
  12819.     scanf("%s", &lpData );
  12820.     len = strlen(lpData);
  12821.     
  12822.     // Have to do this before the Padding...well...it's best anyway;)
  12823.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12824.     
  12825.     // For the strings, we're gonna pad and digest the string
  12826.     // in one pass.
  12827.     MDxInit( &mdDataSum );
  12828.     MDxPad( lpData, len, len );
  12829.     
  12830.     MD5Translate( lpData, len, &mdDataSum );
  12831.         // New step necessary because of the 'chunking' method
  12832.         MDxFinalize( &mdDataSum );
  12833.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12834.     
  12835.     MDxInit( &mdDataSum );
  12836.     MD4Translate( lpData, len, &mdDataSum );    
  12837.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12838.  
  12839.     return;
  12840. }
  12841.  
  12842.  
  12843. -------------- Include
  12844.  
  12845. #ifndef __windows_h__
  12846.         typedef unsigned long DWORD;
  12847.         #define STDCALL _stdcall
  12848. #endif
  12849.  
  12850. typedef struct 
  12851. {
  12852.     DWORD dwSum[4];
  12853. }MDxSum;
  12854.  
  12855. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  12856. void STDCALL MDxInit( MDxSum * );
  12857. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  12858. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  12859. const char * STDCALL MDxGetVersion();
  12860. void STDCALL MDxFinalize( MDxSum * );
  12861.  
  12862.  
  12863.  
  12864. #include "mdx.h"
  12865. #include <stdlib.h>
  12866. #include <stdio.h>
  12867. #include <string.h>
  12868.  
  12869. // READLEN % 64 must = 0
  12870. #define READLEN    1048576L // 2^20, 1MB
  12871.  
  12872. void DigestFile( char * );
  12873. void DigestString();
  12874.  
  12875. void main(int argc, char *argv[])
  12876. {
  12877.     printf("%s\n\n", MDxGetVersion());
  12878.  
  12879.     if( argc > 1 )
  12880.         DigestFile( argv[1] );
  12881.     else    
  12882.         DigestString();
  12883.  
  12884. }
  12885.  
  12886. /*
  12887.     I use the 'chunk' method for processing files not because of
  12888.     limitations of my dll, but think what would happen if you
  12889.     tried to load an entire cd image into memory.
  12890. */
  12891. void DigestFile( char *szFName )
  12892. {
  12893.     FILE *file;
  12894.     void *lpData;
  12895.     long flen, mlen;
  12896.     MDxSum mdDataSum;
  12897.     MDxSum md4DataSum;
  12898.  
  12899.     // the 64 is for padding purposes
  12900.     lpData = malloc( READLEN + 64 );
  12901.     
  12902.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  12903.  
  12904.     file = fopen( szFName, "rb" );
  12905.     if( file == NULL )
  12906.     {
  12907.         printf("ERROR: File not found.\n");
  12908.         return;
  12909.     }
  12910.     
  12911.     MDxInit( &mdDataSum );
  12912.     MDxInit( &md4DataSum );
  12913.     
  12914.     fseek( file, 0, SEEK_END );
  12915.     //Get the file length
  12916.     flen = mlen = ftell( file );
  12917.     fseek( file, 0, SEEK_SET );
  12918.     
  12919.     // When it takes a while to process a large file,
  12920.     // remember that for each chunk it has to run 
  12921.     // through the main translation loop 16384 times!
  12922.         
  12923.     printf("Processing %ld byte file: .", flen );
  12924.     
  12925.     while( flen > READLEN )
  12926.     {
  12927.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  12928.         {
  12929.             printf("READ ERROR!\n");
  12930.             return;
  12931.         }
  12932.         MD5Translate( lpData, READLEN, &mdDataSum );
  12933.         MD4Translate( lpData, READLEN, &md4DataSum );
  12934.         flen -= READLEN;
  12935.         printf(".");
  12936.     }
  12937.  
  12938.     if (fread( lpData, 1, flen, file ) != flen)
  12939.     {
  12940.         printf("READ ERROR!\n");
  12941.         return;
  12942.     }
  12943.     // This is why I added the new argument to MDxPad
  12944.     // So we can pass the length of the data AND the
  12945.     // Total length of the message
  12946.     // Also it now returns the # of padding bytes added,
  12947.     // this is for files that are an exact multiple of the chunk
  12948.     // length. (Otherwise the padding isn't Translated)
  12949.     flen += MDxPad( lpData, flen, mlen );
  12950.     MD5Translate( lpData, flen, &mdDataSum );    
  12951.     MD4Translate( lpData, flen, &md4DataSum );
  12952.  
  12953.     // New step necessary because of the 'chunking' method
  12954.     MDxFinalize( &mdDataSum );
  12955.     MDxFinalize( &md4DataSum );
  12956.     
  12957.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  12958.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12959.     fclose(file);
  12960.         
  12961. }
  12962.  
  12963. void DigestString()
  12964. {
  12965.     
  12966.     //For our demo purposes, no strings bigger than 1024 :)
  12967.     unsigned char lpData[1024] = "";
  12968.     long len = 0;
  12969.     MDxSum mdDataSum;
  12970.  
  12971.     printf("Enter the string to digest: ");
  12972.     scanf("%s", &lpData );
  12973.     len = strlen(lpData);
  12974.     
  12975.     // Have to do this before the Padding...well...it's best anyway;)
  12976.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  12977.     
  12978.     // For the strings, we're gonna pad and digest the string
  12979.     // in one pass.
  12980.     MDxInit( &mdDataSum );
  12981.     MDxPad( lpData, len, len );
  12982.     
  12983.     MD5Translate( lpData, len, &mdDataSum );
  12984.         // New step necessary because of the 'chunking' method
  12985.         MDxFinalize( &mdDataSum );
  12986.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12987.     
  12988.     MDxInit( &mdDataSum );
  12989.     MD4Translate( lpData, len, &mdDataSum );    
  12990.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  12991.  
  12992.     return;
  12993. }
  12994.  
  12995.  
  12996. -------------- Include
  12997.  
  12998. #ifndef __windows_h__
  12999.         typedef unsigned long DWORD;
  13000.         #define STDCALL _stdcall
  13001. #endif
  13002.  
  13003. typedef struct 
  13004. {
  13005.     DWORD dwSum[4];
  13006. }MDxSum;
  13007.  
  13008. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13009. void STDCALL MDxInit( MDxSum * );
  13010. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13011. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13012. const char * STDCALL MDxGetVersion();
  13013. void STDCALL MDxFinalize( MDxSum * );
  13014.  
  13015.  
  13016.  
  13017.  
  13018. #include "mdx.h"
  13019. #include <stdlib.h>
  13020. #include <stdio.h>
  13021. #include <string.h>
  13022.  
  13023. // READLEN % 64 must = 0
  13024. #define READLEN    1048576L // 2^20, 1MB
  13025.  
  13026. void DigestFile( char * );
  13027. void DigestString();
  13028.  
  13029. void main(int argc, char *argv[])
  13030. {
  13031.     printf("%s\n\n", MDxGetVersion());
  13032.  
  13033.     if( argc > 1 )
  13034.         DigestFile( argv[1] );
  13035.     else    
  13036.         DigestString();
  13037.  
  13038. }
  13039.  
  13040. /*
  13041.     I use the 'chunk' method for processing files not because of
  13042.     limitations of my dll, but think what would happen if you
  13043.     tried to load an entire cd image into memory.
  13044. */
  13045. void DigestFile( char *szFName )
  13046. {
  13047.     FILE *file;
  13048.     void *lpData;
  13049.     long flen, mlen;
  13050.     MDxSum mdDataSum;
  13051.     MDxSum md4DataSum;
  13052.  
  13053.     // the 64 is for padding purposes
  13054.     lpData = malloc( READLEN + 64 );
  13055.     
  13056.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13057.  
  13058.     file = fopen( szFName, "rb" );
  13059.     if( file == NULL )
  13060.     {
  13061.         printf("ERROR: File not found.\n");
  13062.         return;
  13063.     }
  13064.     
  13065.     MDxInit( &mdDataSum );
  13066.     MDxInit( &md4DataSum );
  13067.     
  13068.     fseek( file, 0, SEEK_END );
  13069.     //Get the file length
  13070.     flen = mlen = ftell( file );
  13071.     fseek( file, 0, SEEK_SET );
  13072.     
  13073.     // When it takes a while to process a large file,
  13074.     // remember that for each chunk it has to run 
  13075.     // through the main translation loop 16384 times!
  13076.         
  13077.     printf("Processing %ld byte file: .", flen );
  13078.     
  13079.     while( flen > READLEN )
  13080.     {
  13081.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13082.         {
  13083.             printf("READ ERROR!\n");
  13084.             return;
  13085.         }
  13086.         MD5Translate( lpData, READLEN, &mdDataSum );
  13087.         MD4Translate( lpData, READLEN, &md4DataSum );
  13088.         flen -= READLEN;
  13089.         printf(".");
  13090.     }
  13091.  
  13092.     if (fread( lpData, 1, flen, file ) != flen)
  13093.     {
  13094.         printf("READ ERROR!\n");
  13095.         return;
  13096.     }
  13097.     // This is why I added the new argument to MDxPad
  13098.     // So we can pass the length of the data AND the
  13099.     // Total length of the message
  13100.     // Also it now returns the # of padding bytes added,
  13101.     // this is for files that are an exact multiple of the chunk
  13102.     // length. (Otherwise the padding isn't Translated)
  13103.     flen += MDxPad( lpData, flen, mlen );
  13104.     MD5Translate( lpData, flen, &mdDataSum );    
  13105.     MD4Translate( lpData, flen, &md4DataSum );
  13106.  
  13107.     // New step necessary because of the 'chunking' method
  13108.     MDxFinalize( &mdDataSum );
  13109.     MDxFinalize( &md4DataSum );
  13110.     
  13111.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  13112.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13113.     fclose(file);
  13114.         
  13115. }
  13116.  
  13117. void DigestString()
  13118. {
  13119.     
  13120.     //For our demo purposes, no strings bigger than 1024 :)
  13121.     unsigned char lpData[1024] = "";
  13122.     long len = 0;
  13123.     MDxSum mdDataSum;
  13124.  
  13125.     printf("Enter the string to digest: ");
  13126.     scanf("%s", &lpData );
  13127.     len = strlen(lpData);
  13128.     
  13129.     // Have to do this before the Padding...well...it's best anyway;)
  13130.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  13131.     
  13132.     // For the strings, we're gonna pad and digest the string
  13133.     // in one pass.
  13134.     MDxInit( &mdDataSum );
  13135.     MDxPad( lpData, len, len );
  13136.     
  13137.     MD5Translate( lpData, len, &mdDataSum );
  13138.         // New step necessary because of the 'chunking' method
  13139.         MDxFinalize( &mdDataSum );
  13140.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13141.     
  13142.     MDxInit( &mdDataSum );
  13143.     MD4Translate( lpData, len, &mdDataSum );    
  13144.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13145.  
  13146.     return;
  13147. }
  13148.  
  13149.  
  13150. -------------- Include
  13151.  
  13152. #ifndef __windows_h__
  13153.         typedef unsigned long DWORD;
  13154.         #define STDCALL _stdcall
  13155. #endif
  13156.  
  13157. typedef struct 
  13158. {
  13159.     DWORD dwSum[4];
  13160. }MDxSum;
  13161.  
  13162. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13163. void STDCALL MDxInit( MDxSum * );
  13164. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13165. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13166. const char * STDCALL MDxGetVersion();
  13167. void STDCALL MDxFinalize( MDxSum * );
  13168.  
  13169.  
  13170.  
  13171.  
  13172. #include "mdx.h"
  13173. #include <stdlib.h>
  13174. #include <stdio.h>
  13175. #include <string.h>
  13176.  
  13177. // READLEN % 64 must = 0
  13178. #define READLEN    1048576L // 2^20, 1MB
  13179.  
  13180. void DigestFile( char * );
  13181. void DigestString();
  13182.  
  13183. void main(int argc, char *argv[])
  13184. {
  13185.     printf("%s\n\n", MDxGetVersion());
  13186.  
  13187.     if( argc > 1 )
  13188.         DigestFile( argv[1] );
  13189.     else    
  13190.         DigestString();
  13191.  
  13192. }
  13193.  
  13194. /*
  13195.     I use the 'chunk' method for processing files not because of
  13196.     limitations of my dll, but think what would happen if you
  13197.     tried to load an entire cd image into memory.
  13198. */
  13199. void DigestFile( char *szFName )
  13200. {
  13201.     FILE *file;
  13202.     void *lpData;
  13203.     long flen, mlen;
  13204.     MDxSum mdDataSum;
  13205.     MDxSum md4DataSum;
  13206.  
  13207.     // the 64 is for padding purposes
  13208.     lpData = malloc( READLEN + 64 );
  13209.     
  13210.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13211.  
  13212.     file = fopen( szFName, "rb" );
  13213.     if( file == NULL )
  13214.     {
  13215.         printf("ERROR: File not found.\n");
  13216.         return;
  13217.     }
  13218.     
  13219.     MDxInit( &mdDataSum );
  13220.     MDxInit( &md4DataSum );
  13221.     
  13222.     fseek( file, 0, SEEK_END );
  13223.     //Get the file length
  13224.     flen = mlen = ftell( file );
  13225.     fseek( file, 0, SEEK_SET );
  13226.     
  13227.     // When it takes a while to process a large file,
  13228.     // remember that for each chunk it has to run 
  13229.     // through the main translation loop 16384 times!
  13230.         
  13231.     printf("Processing %ld byte file: .", flen );
  13232.     
  13233.     while( flen > READLEN )
  13234.     {
  13235.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13236.         {
  13237.             printf("READ ERROR!\n");
  13238.             return;
  13239.         }
  13240.         MD5Translate( lpData, READLEN, &mdDataSum );
  13241.         MD4Translate( lpData, READLEN, &md4DataSum );
  13242.         flen -= READLEN;
  13243.         printf(".");
  13244.     }
  13245.  
  13246.     if (fread( lpData, 1, flen, file ) != flen)
  13247.     {
  13248.         printf("READ ERROR!\n");
  13249.         return;
  13250.     }
  13251.     // This is why I added the new argument to MDxPad
  13252.     // So we can pass the length of the data AND the
  13253.     // Total length of the message
  13254.     // Also it now returns the # of padding bytes added,
  13255.     // this is for files that are an exact multiple of the chunk
  13256.     // length. (Otherwise the padding isn't Translated)
  13257.     flen += MDxPad( lpData, flen, mlen );
  13258.     MD5Translate( lpData, flen, &mdDataSum );    
  13259.     MD4Translate( lpData, flen, &md4DataSum );
  13260.  
  13261.     // New step necessary because of the 'chunking' method
  13262.     MDxFinalize( &mdDataSum );
  13263.     MDxFinalize( &md4DataSum );
  13264.     
  13265.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  13266.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13267.     fclose(file);
  13268.         
  13269. }
  13270.  
  13271. void DigestString()
  13272. {
  13273.     
  13274.     //For our demo purposes, no strings bigger than 1024 :)
  13275.     unsigned char lpData[1024] = "";
  13276.     long len = 0;
  13277.     MDxSum mdDataSum;
  13278.  
  13279.     printf("Enter the string to digest: ");
  13280.     scanf("%s", &lpData );
  13281.     len = strlen(lpData);
  13282.     
  13283.     // Have to do this before the Padding...well...it's best anyway;)
  13284.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  13285.     
  13286.     // For the strings, we're gonna pad and digest the string
  13287.     // in one pass.
  13288.     MDxInit( &mdDataSum );
  13289.     MDxPad( lpData, len, len );
  13290.     
  13291.     MD5Translate( lpData, len, &mdDataSum );
  13292.         // New step necessary because of the 'chunking' method
  13293.         MDxFinalize( &mdDataSum );
  13294.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13295.     
  13296.     MDxInit( &mdDataSum );
  13297.     MD4Translate( lpData, len, &mdDataSum );    
  13298.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13299.  
  13300.     return;
  13301. }
  13302.  
  13303.  
  13304. -------------- Include
  13305.  
  13306. #ifndef __windows_h__
  13307.         typedef unsigned long DWORD;
  13308.         #define STDCALL _stdcall
  13309. #endif
  13310.  
  13311. typedef struct 
  13312. {
  13313.     DWORD dwSum[4];
  13314. }MDxSum;
  13315.  
  13316. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13317. void STDCALL MDxInit( MDxSum * );
  13318. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13319. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13320. const char * STDCALL MDxGetVersion();
  13321. void STDCALL MDxFinalize( MDxSum * );
  13322.  
  13323.  
  13324.  
  13325. #include "mdx.h"
  13326. #include <stdlib.h>
  13327. #include <stdio.h>
  13328. #include <string.h>
  13329.  
  13330. // READLEN % 64 must = 0
  13331. #define READLEN    1048576L // 2^20, 1MB
  13332.  
  13333. void DigestFile( char * );
  13334. void DigestString();
  13335.  
  13336. void main(int argc, char *argv[])
  13337. {
  13338.     printf("%s\n\n", MDxGetVersion());
  13339.  
  13340.     if( argc > 1 )
  13341.         DigestFile( argv[1] );
  13342.     else    
  13343.         DigestString();
  13344.  
  13345. }
  13346.  
  13347. /*
  13348.     I use the 'chunk' method for processing files not because of
  13349.     limitations of my dll, but think what would happen if you
  13350.     tried to load an entire cd image into memory.
  13351. */
  13352. void DigestFile( char *szFName )
  13353. {
  13354.     FILE *file;
  13355.     void *lpData;
  13356.     long flen, mlen;
  13357.     MDxSum mdDataSum;
  13358.     MDxSum md4DataSum;
  13359.  
  13360.     // the 64 is for padding purposes
  13361.     lpData = malloc( READLEN + 64 );
  13362.     
  13363.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13364.  
  13365.     file = fopen( szFName, "rb" );
  13366.     if( file == NULL )
  13367.     {
  13368.         printf("ERROR: File not found.\n");
  13369.         return;
  13370.     }
  13371.     
  13372.     MDxInit( &mdDataSum );
  13373.     MDxInit( &md4DataSum );
  13374.     
  13375.     fseek( file, 0, SEEK_END );
  13376.     //Get the file length
  13377.     flen = mlen = ftell( file );
  13378.     fseek( file, 0, SEEK_SET );
  13379.     
  13380.     // When it takes a while to process a large file,
  13381.     // remember that for each chunk it has to run 
  13382.     // through the main translation loop 16384 times!
  13383.         
  13384.     printf("Processing %ld byte file: .", flen );
  13385.     
  13386.     while( flen > READLEN )
  13387.     {
  13388.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13389.         {
  13390.             printf("READ ERROR!\n");
  13391.             return;
  13392.         }
  13393.         MD5Translate( lpData, READLEN, &mdDataSum );
  13394.         MD4Translate( lpData, READLEN, &md4DataSum );
  13395.         flen -= READLEN;
  13396.         printf(".");
  13397.     }
  13398.  
  13399.     if (fread( lpData, 1, flen, file ) != flen)
  13400.     {
  13401.         printf("READ ERROR!\n");
  13402.         return;
  13403.     }
  13404.     // This is why I added the new argument to MDxPad
  13405.     // So we can pass the length of the data AND the
  13406.     // Total length of the message
  13407.     // Also it now returns the # of padding bytes added,
  13408.     // this is for files that are an exact multiple of the chunk
  13409.     // length. (Otherwise the padding isn't Translated)
  13410.     flen += MDxPad( lpData, flen, mlen );
  13411.     MD5Translate( lpData, flen, &mdDataSum );    
  13412.     MD4Translate( lpData, flen, &md4DataSum );
  13413.  
  13414.     // New step necessary because of the 'chunking' method
  13415.     MDxFinalize( &mdDataSum );
  13416.     MDxFinalize( &md4DataSum );
  13417.     
  13418.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  13419.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13420.     fclose(file);
  13421.         
  13422. }
  13423.  
  13424. void DigestString()
  13425. {
  13426.     
  13427.     //For our demo purposes, no strings bigger than 1024 :)
  13428.     unsigned char lpData[1024] = "";
  13429.     long len = 0;
  13430.     MDxSum mdDataSum;
  13431.  
  13432.     printf("Enter the string to digest: ");
  13433.     scanf("%s", &lpData );
  13434.     len = strlen(lpData);
  13435.     
  13436.     // Have to do this before the Padding...well...it's best anyway;)
  13437.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  13438.     
  13439.     // For the strings, we're gonna pad and digest the string
  13440.     // in one pass.
  13441.     MDxInit( &mdDataSum );
  13442.     MDxPad( lpData, len, len );
  13443.     
  13444.     MD5Translate( lpData, len, &mdDataSum );
  13445.         // New step necessary because of the 'chunking' method
  13446.         MDxFinalize( &mdDataSum );
  13447.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13448.     
  13449.     MDxInit( &mdDataSum );
  13450.     MD4Translate( lpData, len, &mdDataSum );    
  13451.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13452.  
  13453.     return;
  13454. }
  13455.  
  13456.  
  13457. -------------- Include
  13458.  
  13459. #ifndef __windows_h__
  13460.         typedef unsigned long DWORD;
  13461.         #define STDCALL _stdcall
  13462. #endif
  13463.  
  13464. typedef struct 
  13465. {
  13466.     DWORD dwSum[4];
  13467. }MDxSum;
  13468.  
  13469. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13470. void STDCALL MDxInit( MDxSum * );
  13471. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13472. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13473. const char * STDCALL MDxGetVersion();
  13474. void STDCALL MDxFinalize( MDxSum * );
  13475.  
  13476.  
  13477. #include "mdx.h"
  13478. #include <stdlib.h>
  13479. #include <stdio.h>
  13480. #include <string.h>
  13481.  
  13482. // READLEN % 64 must = 0
  13483. #define READLEN    1048576L // 2^20, 1MB
  13484.  
  13485. void DigestFile( char * );
  13486. void DigestString();
  13487.  
  13488. void main(int argc, char *argv[])
  13489. {
  13490.     printf("%s\n\n", MDxGetVersion());
  13491.  
  13492.     if( argc > 1 )
  13493.         DigestFile( argv[1] );
  13494.     else    
  13495.         DigestString();
  13496.  
  13497. }
  13498.  
  13499. /*
  13500.     I use the 'chunk' method for processing files not because of
  13501.     limitations of my dll, but think what would happen if you
  13502.     tried to load an entire cd image into memory.
  13503. */
  13504. void DigestFile( char *szFName )
  13505. {
  13506.     FILE *file;
  13507.     void *lpData;
  13508.     long flen, mlen;
  13509.     MDxSum mdDataSum;
  13510.     MDxSum md4DataSum;
  13511.  
  13512.     // the 64 is for padding purposes
  13513.     lpData = malloc( READLEN + 64 );
  13514.     
  13515.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13516.  
  13517.     file = fopen( szFName, "rb" );
  13518.     if( file == NULL )
  13519.     {
  13520.         printf("ERROR: File not found.\n");
  13521.         return;
  13522.     }
  13523.     
  13524.     MDxInit( &mdDataSum );
  13525.     MDxInit( &md4DataSum );
  13526.     
  13527.     fseek( file, 0, SEEK_END );
  13528.     //Get the file length
  13529.     flen = mlen = ftell( file );
  13530.     fseek( file, 0, SEEK_SET );
  13531.     
  13532.     // When it takes a while to process a large file,
  13533.     // remember that for each chunk it has to run 
  13534.     // through the main translation loop 16384 times!
  13535.         
  13536.     printf("Processing %ld byte file: .", flen );
  13537.     
  13538.     while( flen > READLEN )
  13539.     {
  13540.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13541.         {
  13542.             printf("READ ERROR!\n");
  13543.             return;
  13544.         }
  13545.         MD5Translate( lpData, READLEN, &mdDataSum );
  13546.         MD4Translate( lpData, READLEN, &md4DataSum );
  13547.         flen -= READLEN;
  13548.         printf(".");
  13549.     }
  13550.  
  13551.     if (fread( lpData, 1, flen, file ) != flen)
  13552.     {
  13553.         printf("READ ERROR!\n");
  13554.         return;
  13555.     }
  13556.     // This is why I added the new argument to MDxPad
  13557.     // So we can pass the length of the data AND the
  13558.     // Total length of the message
  13559.     // Also it now returns the # of padding bytes added,
  13560.     // this is for files that are an exact multiple of the chunk
  13561.     // length. (Otherwise the padding isn't Translated)
  13562.     flen += MDxPad( lpData, flen, mlen );
  13563.     MD5Translate( lpData, flen, &mdDataSum );    
  13564.     MD4Translate( lpData, flen, &md4DataSum );
  13565.  
  13566.     // New step necessary because of the 'chunking' method
  13567.     MDxFinalize( &mdDataSum );
  13568.     MDxFinalize( &md4DataSum );
  13569.     
  13570.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  13571.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13572.     fclose(file);
  13573.         
  13574. }
  13575.  
  13576. void DigestString()
  13577. {
  13578.     
  13579.     //For our demo purposes, no strings bigger than 1024 :)
  13580.     unsigned char lpData[1024] = "";
  13581.     long len = 0;
  13582.     MDxSum mdDataSum;
  13583.  
  13584.     printf("Enter the string to digest: ");
  13585.     scanf("%s", &lpData );
  13586.     len = strlen(lpData);
  13587.     
  13588.     // Have to do this before the Padding...well...it's best anyway;)
  13589.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  13590.     
  13591.     // For the strings, we're gonna pad and digest the string
  13592.     // in one pass.
  13593.     MDxInit( &mdDataSum );
  13594.     MDxPad( lpData, len, len );
  13595.     
  13596.     MD5Translate( lpData, len, &mdDataSum );
  13597.         // New step necessary because of the 'chunking' method
  13598.         MDxFinalize( &mdDataSum );
  13599.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13600.     
  13601.     MDxInit( &mdDataSum );
  13602.     MD4Translate( lpData, len, &mdDataSum );    
  13603.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13604.  
  13605.     return;
  13606. }
  13607.  
  13608.  
  13609. -------------- Include
  13610.  
  13611. #ifndef __windows_h__
  13612.         typedef unsigned long DWORD;
  13613.         #define STDCALL _stdcall
  13614. #endif
  13615.  
  13616. typedef struct 
  13617. {
  13618.     DWORD dwSum[4];
  13619. }MDxSum;
  13620.  
  13621. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13622. void STDCALL MDxInit( MDxSum * );
  13623. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13624. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13625. const char * STDCALL MDxGetVersion();
  13626. void STDCALL MDxFinalize( MDxSum * );
  13627.  
  13628.  
  13629.  
  13630. #include "mdx.h"
  13631. #include <stdlib.h>
  13632. #include <stdio.h>
  13633. #include <string.h>
  13634.  
  13635. // READLEN % 64 must = 0
  13636. #define READLEN    1048576L // 2^20, 1MB
  13637.  
  13638. void DigestFile( char * );
  13639. void DigestString();
  13640.  
  13641. void main(int argc, char *argv[])
  13642. {
  13643.     printf("%s\n\n", MDxGetVersion());
  13644.  
  13645.     if( argc > 1 )
  13646.         DigestFile( argv[1] );
  13647.     else    
  13648.         DigestString();
  13649.  
  13650. }
  13651.  
  13652. /*
  13653.     I use the 'chunk' method for processing files not because of
  13654.     limitations of my dll, but think what would happen if you
  13655.     tried to load an entire cd image into memory.
  13656. */
  13657. void DigestFile( char *szFName )
  13658. {
  13659.     FILE *file;
  13660.     void *lpData;
  13661.     long flen, mlen;
  13662.     MDxSum mdDataSum;
  13663.     MDxSum md4DataSum;
  13664.  
  13665.     // the 64 is for padding purposes
  13666.     lpData = malloc( READLEN + 64 );
  13667.     
  13668.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13669.  
  13670.     file = fopen( szFName, "rb" );
  13671.     if( file == NULL )
  13672.     {
  13673.         printf("ERROR: File not found.\n");
  13674.         return;
  13675.     }
  13676.     
  13677.     MDxInit( &mdDataSum );
  13678.     MDxInit( &md4DataSum );
  13679.     
  13680.     fseek( file, 0, SEEK_END );
  13681.     //Get the file length
  13682.     flen = mlen = ftell( file );
  13683.     fseek( file, 0, SEEK_SET );
  13684.     
  13685.     // When it takes a while to process a large file,
  13686.     // remember that for each chunk it has to run 
  13687.     // through the main translation loop 16384 times!
  13688.         
  13689.     printf("Processing %ld byte file: .", flen );
  13690.     
  13691.     while( flen > READLEN )
  13692.     {
  13693.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13694.         {
  13695.             printf("READ ERROR!\n");
  13696.             return;
  13697.         }
  13698.         MD5Translate( lpData, READLEN, &mdDataSum );
  13699.         MD4Translate( lpData, READLEN, &md4DataSum );
  13700.         flen -= READLEN;
  13701.         printf(".");
  13702.     }
  13703.  
  13704.     if (fread( lpData, 1, flen, file ) != flen)
  13705.     {
  13706.         printf("READ ERROR!\n");
  13707.         return;
  13708.     }
  13709.     // This is why I added the new argument to MDxPad
  13710.     // So we can pass the length of the data AND the
  13711.     // Total length of the message
  13712.     // Also it now returns the # of padding bytes added,
  13713.     // this is for files that are an exact multiple of the chunk
  13714.     // length. (Otherwise the padding isn't Translated)
  13715.     flen += MDxPad( lpData, flen, mlen );
  13716.     MD5Translate( lpData, flen, &mdDataSum );    
  13717.     MD4Translate( lpData, flen, &md4DataSum );
  13718.  
  13719.     // New step necessary because of the 'chunking' method
  13720.     MDxFinalize( &mdDataSum );
  13721.     MDxFinalize( &md4DataSum );
  13722.     
  13723.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  13724.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13725.     fclose(file);
  13726.         
  13727. }
  13728.  
  13729. void DigestString()
  13730. {
  13731.     
  13732.     //For our demo purposes, no strings bigger than 1024 :)
  13733.     unsigned char lpData[1024] = "";
  13734.     long len = 0;
  13735.     MDxSum mdDataSum;
  13736.  
  13737.     printf("Enter the string to digest: ");
  13738.     scanf("%s", &lpData );
  13739.     len = strlen(lpData);
  13740.     
  13741.     // Have to do this before the Padding...well...it's best anyway;)
  13742.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  13743.     
  13744.     // For the strings, we're gonna pad and digest the string
  13745.     // in one pass.
  13746.     MDxInit( &mdDataSum );
  13747.     MDxPad( lpData, len, len );
  13748.     
  13749.     MD5Translate( lpData, len, &mdDataSum );
  13750.         // New step necessary because of the 'chunking' method
  13751.         MDxFinalize( &mdDataSum );
  13752.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13753.     
  13754.     MDxInit( &mdDataSum );
  13755.     MD4Translate( lpData, len, &mdDataSum );    
  13756.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13757.  
  13758.     return;
  13759. }
  13760.  
  13761.  
  13762. -------------- Include
  13763.  
  13764. #ifndef __windows_h__
  13765.         typedef unsigned long DWORD;
  13766.         #define STDCALL _stdcall
  13767. #endif
  13768.  
  13769. typedef struct 
  13770. {
  13771.     DWORD dwSum[4];
  13772. }MDxSum;
  13773.  
  13774. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13775. void STDCALL MDxInit( MDxSum * );
  13776. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13777. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13778. const char * STDCALL MDxGetVersion();
  13779. void STDCALL MDxFinalize( MDxSum * );
  13780.  
  13781.  
  13782.  
  13783. #include "mdx.h"
  13784. #include <stdlib.h>
  13785. #include <stdio.h>
  13786. #include <string.h>
  13787.  
  13788. // READLEN % 64 must = 0
  13789. #define READLEN    1048576L // 2^20, 1MB
  13790.  
  13791. void DigestFile( char * );
  13792. void DigestString();
  13793.  
  13794. void main(int argc, char *argv[])
  13795. {
  13796.     printf("%s\n\n", MDxGetVersion());
  13797.  
  13798.     if( argc > 1 )
  13799.         DigestFile( argv[1] );
  13800.     else    
  13801.         DigestString();
  13802.  
  13803. }
  13804.  
  13805. /*
  13806.     I use the 'chunk' method for processing files not because of
  13807.     limitations of my dll, but think what would happen if you
  13808.     tried to load an entire cd image into memory.
  13809. */
  13810. void DigestFile( char *szFName )
  13811. {
  13812.     FILE *file;
  13813.     void *lpData;
  13814.     long flen, mlen;
  13815.     MDxSum mdDataSum;
  13816.     MDxSum md4DataSum;
  13817.  
  13818.     // the 64 is for padding purposes
  13819.     lpData = malloc( READLEN + 64 );
  13820.     
  13821.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13822.  
  13823.     file = fopen( szFName, "rb" );
  13824.     if( file == NULL )
  13825.     {
  13826.         printf("ERROR: File not found.\n");
  13827.         return;
  13828.     }
  13829.     
  13830.     MDxInit( &mdDataSum );
  13831.     MDxInit( &md4DataSum );
  13832.     
  13833.     fseek( file, 0, SEEK_END );
  13834.     //Get the file length
  13835.     flen = mlen = ftell( file );
  13836.     fseek( file, 0, SEEK_SET );
  13837.     
  13838.     // When it takes a while to process a large file,
  13839.     // remember that for each chunk it has to run 
  13840.     // through the main translation loop 16384 times!
  13841.         
  13842.     printf("Processing %ld byte file: .", flen );
  13843.     
  13844.     while( flen > READLEN )
  13845.     {
  13846.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13847.         {
  13848.             printf("READ ERROR!\n");
  13849.             return;
  13850.         }
  13851.         MD5Translate( lpData, READLEN, &mdDataSum );
  13852.         MD4Translate( lpData, READLEN, &md4DataSum );
  13853.         flen -= READLEN;
  13854.         printf(".");
  13855.     }
  13856.  
  13857.     if (fread( lpData, 1, flen, file ) != flen)
  13858.     {
  13859.         printf("READ ERROR!\n");
  13860.         return;
  13861.     }
  13862.     // This is why I added the new argument to MDxPad
  13863.     // So we can pass the length of the data AND the
  13864.     // Total length of the message
  13865.     // Also it now returns the # of padding bytes added,
  13866.     // this is for files that are an exact multiple of the chunk
  13867.     // length. (Otherwise the padding isn't Translated)
  13868.     flen += MDxPad( lpData, flen, mlen );
  13869.     MD5Translate( lpData, flen, &mdDataSum );    
  13870.     MD4Translate( lpData, flen, &md4DataSum );
  13871.  
  13872.     // New step necessary because of the 'chunking' method
  13873.     MDxFinalize( &mdDataSum );
  13874.     MDxFinalize( &md4DataSum );
  13875.     
  13876.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  13877.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13878.     fclose(file);
  13879.         
  13880. }
  13881.  
  13882. void DigestString()
  13883. {
  13884.     
  13885.     //For our demo purposes, no strings bigger than 1024 :)
  13886.     unsigned char lpData[1024] = "";
  13887.     long len = 0;
  13888.     MDxSum mdDataSum;
  13889.  
  13890.     printf("Enter the string to digest: ");
  13891.     scanf("%s", &lpData );
  13892.     len = strlen(lpData);
  13893.     
  13894.     // Have to do this before the Padding...well...it's best anyway;)
  13895.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  13896.     
  13897.     // For the strings, we're gonna pad and digest the string
  13898.     // in one pass.
  13899.     MDxInit( &mdDataSum );
  13900.     MDxPad( lpData, len, len );
  13901.     
  13902.     MD5Translate( lpData, len, &mdDataSum );
  13903.         // New step necessary because of the 'chunking' method
  13904.         MDxFinalize( &mdDataSum );
  13905.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13906.     
  13907.     MDxInit( &mdDataSum );
  13908.     MD4Translate( lpData, len, &mdDataSum );    
  13909.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  13910.  
  13911.     return;
  13912. }
  13913.  
  13914.  
  13915. -------------- Include
  13916.  
  13917. #ifndef __windows_h__
  13918.         typedef unsigned long DWORD;
  13919.         #define STDCALL _stdcall
  13920. #endif
  13921.  
  13922. typedef struct 
  13923. {
  13924.     DWORD dwSum[4];
  13925. }MDxSum;
  13926.  
  13927. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  13928. void STDCALL MDxInit( MDxSum * );
  13929. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  13930. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  13931. const char * STDCALL MDxGetVersion();
  13932. void STDCALL MDxFinalize( MDxSum * );
  13933.  
  13934.  
  13935. #include "mdx.h"
  13936. #include <stdlib.h>
  13937. #include <stdio.h>
  13938. #include <string.h>
  13939.  
  13940. // READLEN % 64 must = 0
  13941. #define READLEN    1048576L // 2^20, 1MB
  13942.  
  13943. void DigestFile( char * );
  13944. void DigestString();
  13945.  
  13946. void main(int argc, char *argv[])
  13947. {
  13948.     printf("%s\n\n", MDxGetVersion());
  13949.  
  13950.     if( argc > 1 )
  13951.         DigestFile( argv[1] );
  13952.     else    
  13953.         DigestString();
  13954.  
  13955. }
  13956.  
  13957. /*
  13958.     I use the 'chunk' method for processing files not because of
  13959.     limitations of my dll, but think what would happen if you
  13960.     tried to load an entire cd image into memory.
  13961. */
  13962. void DigestFile( char *szFName )
  13963. {
  13964.     FILE *file;
  13965.     void *lpData;
  13966.     long flen, mlen;
  13967.     MDxSum mdDataSum;
  13968.     MDxSum md4DataSum;
  13969.  
  13970.     // the 64 is for padding purposes
  13971.     lpData = malloc( READLEN + 64 );
  13972.     
  13973.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  13974.  
  13975.     file = fopen( szFName, "rb" );
  13976.     if( file == NULL )
  13977.     {
  13978.         printf("ERROR: File not found.\n");
  13979.         return;
  13980.     }
  13981.     
  13982.     MDxInit( &mdDataSum );
  13983.     MDxInit( &md4DataSum );
  13984.     
  13985.     fseek( file, 0, SEEK_END );
  13986.     //Get the file length
  13987.     flen = mlen = ftell( file );
  13988.     fseek( file, 0, SEEK_SET );
  13989.     
  13990.     // When it takes a while to process a large file,
  13991.     // remember that for each chunk it has to run 
  13992.     // through the main translation loop 16384 times!
  13993.         
  13994.     printf("Processing %ld byte file: .", flen );
  13995.     
  13996.     while( flen > READLEN )
  13997.     {
  13998.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  13999.         {
  14000.             printf("READ ERROR!\n");
  14001.             return;
  14002.         }
  14003.         MD5Translate( lpData, READLEN, &mdDataSum );
  14004.         MD4Translate( lpData, READLEN, &md4DataSum );
  14005.         flen -= READLEN;
  14006.         printf(".");
  14007.     }
  14008.  
  14009.     if (fread( lpData, 1, flen, file ) != flen)
  14010.     {
  14011.         printf("READ ERROR!\n");
  14012.         return;
  14013.     }
  14014.     // This is why I added the new argument to MDxPad
  14015.     // So we can pass the length of the data AND the
  14016.     // Total length of the message
  14017.     // Also it now returns the # of padding bytes added,
  14018.     // this is for files that are an exact multiple of the chunk
  14019.     // length. (Otherwise the padding isn't Translated)
  14020.     flen += MDxPad( lpData, flen, mlen );
  14021.     MD5Translate( lpData, flen, &mdDataSum );    
  14022.     MD4Translate( lpData, flen, &md4DataSum );
  14023.  
  14024.     // New step necessary because of the 'chunking' method
  14025.     MDxFinalize( &mdDataSum );
  14026.     MDxFinalize( &md4DataSum );
  14027.     
  14028.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14029.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14030.     fclose(file);
  14031.         
  14032. }
  14033.  
  14034. void DigestString()
  14035. {
  14036.     
  14037.     //For our demo purposes, no strings bigger than 1024 :)
  14038.     unsigned char lpData[1024] = "";
  14039.     long len = 0;
  14040.     MDxSum mdDataSum;
  14041.  
  14042.     printf("Enter the string to digest: ");
  14043.     scanf("%s", &lpData );
  14044.     len = strlen(lpData);
  14045.     
  14046.     // Have to do this before the Padding...well...it's best anyway;)
  14047.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14048.     
  14049.     // For the strings, we're gonna pad and digest the string
  14050.     // in one pass.
  14051.     MDxInit( &mdDataSum );
  14052.     MDxPad( lpData, len, len );
  14053.     
  14054.     MD5Translate( lpData, len, &mdDataSum );
  14055.         // New step necessary because of the 'chunking' method
  14056.         MDxFinalize( &mdDataSum );
  14057.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14058.     
  14059.     MDxInit( &mdDataSum );
  14060.     MD4Translate( lpData, len, &mdDataSum );    
  14061.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14062.  
  14063.     return;
  14064. }
  14065.  
  14066.  
  14067. -------------- Include
  14068.  
  14069. #ifndef __windows_h__
  14070.         typedef unsigned long DWORD;
  14071.         #define STDCALL _stdcall
  14072. #endif
  14073.  
  14074. typedef struct 
  14075. {
  14076.     DWORD dwSum[4];
  14077. }MDxSum;
  14078.  
  14079. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14080. void STDCALL MDxInit( MDxSum * );
  14081. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14082. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  14083. const char * STDCALL MDxGetVersion();
  14084. void STDCALL MDxFinalize( MDxSum * );
  14085.  
  14086.  
  14087. #include "mdx.h"
  14088. #include <stdlib.h>
  14089. #include <stdio.h>
  14090. #include <string.h>
  14091.  
  14092. // READLEN % 64 must = 0
  14093. #define READLEN    1048576L // 2^20, 1MB
  14094.  
  14095. void DigestFile( char * );
  14096. void DigestString();
  14097.  
  14098. void main(int argc, char *argv[])
  14099. {
  14100.     printf("%s\n\n", MDxGetVersion());
  14101.  
  14102.     if( argc > 1 )
  14103.         DigestFile( argv[1] );
  14104.     else    
  14105.         DigestString();
  14106.  
  14107. }
  14108.  
  14109. /*
  14110.     I use the 'chunk' method for processing files not because of
  14111.     limitations of my dll, but think what would happen if you
  14112.     tried to load an entire cd image into memory.
  14113. */
  14114. void DigestFile( char *szFName )
  14115. {
  14116.     FILE *file;
  14117.     void *lpData;
  14118.     long flen, mlen;
  14119.     MDxSum mdDataSum;
  14120.     MDxSum md4DataSum;
  14121.  
  14122.     // the 64 is for padding purposes
  14123.     lpData = malloc( READLEN + 64 );
  14124.     
  14125.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  14126.  
  14127.     file = fopen( szFName, "rb" );
  14128.     if( file == NULL )
  14129.     {
  14130.         printf("ERROR: File not found.\n");
  14131.         return;
  14132.     }
  14133.     
  14134.     MDxInit( &mdDataSum );
  14135.     MDxInit( &md4DataSum );
  14136.     
  14137.     fseek( file, 0, SEEK_END );
  14138.     //Get the file length
  14139.     flen = mlen = ftell( file );
  14140.     fseek( file, 0, SEEK_SET );
  14141.     
  14142.     // When it takes a while to process a large file,
  14143.     // remember that for each chunk it has to run 
  14144.     // through the main translation loop 16384 times!
  14145.         
  14146.     printf("Processing %ld byte file: .", flen );
  14147.     
  14148.     while( flen > READLEN )
  14149.     {
  14150.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  14151.         {
  14152.             printf("READ ERROR!\n");
  14153.             return;
  14154.         }
  14155.         MD5Translate( lpData, READLEN, &mdDataSum );
  14156.         MD4Translate( lpData, READLEN, &md4DataSum );
  14157.         flen -= READLEN;
  14158.         printf(".");
  14159.     }
  14160.  
  14161.     if (fread( lpData, 1, flen, file ) != flen)
  14162.     {
  14163.         printf("READ ERROR!\n");
  14164.         return;
  14165.     }
  14166.     // This is why I added the new argument to MDxPad
  14167.     // So we can pass the length of the data AND the
  14168.     // Total length of the message
  14169.     // Also it now returns the # of padding bytes added,
  14170.     // this is for files that are an exact multiple of the chunk
  14171.     // length. (Otherwise the padding isn't Translated)
  14172.     flen += MDxPad( lpData, flen, mlen );
  14173.     MD5Translate( lpData, flen, &mdDataSum );    
  14174.     MD4Translate( lpData, flen, &md4DataSum );
  14175.  
  14176.     // New step necessary because of the 'chunking' method
  14177.     MDxFinalize( &mdDataSum );
  14178.     MDxFinalize( &md4DataSum );
  14179.     
  14180.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14181.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14182.     fclose(file);
  14183.         
  14184. }
  14185.  
  14186. void DigestString()
  14187. {
  14188.     
  14189.     //For our demo purposes, no strings bigger than 1024 :)
  14190.     unsigned char lpData[1024] = "";
  14191.     long len = 0;
  14192.     MDxSum mdDataSum;
  14193.  
  14194.     printf("Enter the string to digest: ");
  14195.     scanf("%s", &lpData );
  14196.     len = strlen(lpData);
  14197.     
  14198.     // Have to do this before the Padding...well...it's best anyway;)
  14199.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14200.     
  14201.     // For the strings, we're gonna pad and digest the string
  14202.     // in one pass.
  14203.     MDxInit( &mdDataSum );
  14204.     MDxPad( lpData, len, len );
  14205.     
  14206.     MD5Translate( lpData, len, &mdDataSum );
  14207.         // New step necessary because of the 'chunking' method
  14208.         MDxFinalize( &mdDataSum );
  14209.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14210.     
  14211.     MDxInit( &mdDataSum );
  14212.     MD4Translate( lpData, len, &mdDataSum );    
  14213.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14214.  
  14215.     return;
  14216. }
  14217.  
  14218.  
  14219. -------------- Include
  14220.  
  14221. #ifndef __windows_h__
  14222.         typedef unsigned long DWORD;
  14223.         #define STDCALL _stdcall
  14224. #endif
  14225.  
  14226. typedef struct 
  14227. {
  14228.     DWORD dwSum[4];
  14229. }MDxSum;
  14230.  
  14231. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14232. void STDCALL MDxInit( MDxSum * );
  14233. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14234. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  14235. const char * STDCALL MDxGetVersion();
  14236. void STDCALL MDxFinalize( MDxSum * );
  14237.  
  14238.  
  14239.  
  14240. #include "mdx.h"
  14241. #include <stdlib.h>
  14242. #include <stdio.h>
  14243. #include <string.h>
  14244.  
  14245. // READLEN % 64 must = 0
  14246. #define READLEN    1048576L // 2^20, 1MB
  14247.  
  14248. void DigestFile( char * );
  14249. void DigestString();
  14250.  
  14251. void main(int argc, char *argv[])
  14252. {
  14253.     printf("%s\n\n", MDxGetVersion());
  14254.  
  14255.     if( argc > 1 )
  14256.         DigestFile( argv[1] );
  14257.     else    
  14258.         DigestString();
  14259.  
  14260. }
  14261.  
  14262. /*
  14263.     I use the 'chunk' method for processing files not because of
  14264.     limitations of my dll, but think what would happen if you
  14265.     tried to load an entire cd image into memory.
  14266. */
  14267. void DigestFile( char *szFName )
  14268. {
  14269.     FILE *file;
  14270.     void *lpData;
  14271.     long flen, mlen;
  14272.     MDxSum mdDataSum;
  14273.     MDxSum md4DataSum;
  14274.  
  14275.     // the 64 is for padding purposes
  14276.     lpData = malloc( READLEN + 64 );
  14277.     
  14278.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  14279.  
  14280.     file = fopen( szFName, "rb" );
  14281.     if( file == NULL )
  14282.     {
  14283.         printf("ERROR: File not found.\n");
  14284.         return;
  14285.     }
  14286.     
  14287.     MDxInit( &mdDataSum );
  14288.     MDxInit( &md4DataSum );
  14289.     
  14290.     fseek( file, 0, SEEK_END );
  14291.     //Get the file length
  14292.     flen = mlen = ftell( file );
  14293.     fseek( file, 0, SEEK_SET );
  14294.     
  14295.     // When it takes a while to process a large file,
  14296.     // remember that for each chunk it has to run 
  14297.     // through the main translation loop 16384 times!
  14298.         
  14299.     printf("Processing %ld byte file: .", flen );
  14300.     
  14301.     while( flen > READLEN )
  14302.     {
  14303.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  14304.         {
  14305.             printf("READ ERROR!\n");
  14306.             return;
  14307.         }
  14308.         MD5Translate( lpData, READLEN, &mdDataSum );
  14309.         MD4Translate( lpData, READLEN, &md4DataSum );
  14310.         flen -= READLEN;
  14311.         printf(".");
  14312.     }
  14313.  
  14314.     if (fread( lpData, 1, flen, file ) != flen)
  14315.     {
  14316.         printf("READ ERROR!\n");
  14317.         return;
  14318.     }
  14319.     // This is why I added the new argument to MDxPad
  14320.     // So we can pass the length of the data AND the
  14321.     // Total length of the message
  14322.     // Also it now returns the # of padding bytes added,
  14323.     // this is for files that are an exact multiple of the chunk
  14324.     // length. (Otherwise the padding isn't Translated)
  14325.     flen += MDxPad( lpData, flen, mlen );
  14326.     MD5Translate( lpData, flen, &mdDataSum );    
  14327.     MD4Translate( lpData, flen, &md4DataSum );
  14328.  
  14329.     // New step necessary because of the 'chunking' method
  14330.     MDxFinalize( &mdDataSum );
  14331.     MDxFinalize( &md4DataSum );
  14332.     
  14333.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14334.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14335.     fclose(file);
  14336.         
  14337. }
  14338.  
  14339. void DigestString()
  14340. {
  14341.     
  14342.     //For our demo purposes, no strings bigger than 1024 :)
  14343.     unsigned char lpData[1024] = "";
  14344.     long len = 0;
  14345.     MDxSum mdDataSum;
  14346.  
  14347.     printf("Enter the string to digest: ");
  14348.     scanf("%s", &lpData );
  14349.     len = strlen(lpData);
  14350.     
  14351.     // Have to do this before the Padding...well...it's best anyway;)
  14352.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14353.     
  14354.     // For the strings, we're gonna pad and digest the string
  14355.     // in one pass.
  14356.     MDxInit( &mdDataSum );
  14357.     MDxPad( lpData, len, len );
  14358.     
  14359.     MD5Translate( lpData, len, &mdDataSum );
  14360.         // New step necessary because of the 'chunking' method
  14361.         MDxFinalize( &mdDataSum );
  14362.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14363.     
  14364.     MDxInit( &mdDataSum );
  14365.     MD4Translate( lpData, len, &mdDataSum );    
  14366.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14367.  
  14368.     return;
  14369. }
  14370.  
  14371.  
  14372. -------------- Include
  14373.  
  14374. #ifndef __windows_h__
  14375.         typedef unsigned long DWORD;
  14376.         #define STDCALL _stdcall
  14377. #endif
  14378.  
  14379. typedef struct 
  14380. {
  14381.     DWORD dwSum[4];
  14382. }MDxSum;
  14383.  
  14384. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14385. void STDCALL MDxInit( MDxSum * );
  14386. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14387. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  14388. const char * STDCALL MDxGetVersion();
  14389. void STDCALL MDxFinalize( MDxSum * );
  14390.  
  14391.  
  14392.  
  14393. #include "mdx.h"
  14394. #include <stdlib.h>
  14395. #include <stdio.h>
  14396. #include <string.h>
  14397.  
  14398. // READLEN % 64 must = 0
  14399. #define READLEN    1048576L // 2^20, 1MB
  14400.  
  14401. void DigestFile( char * );
  14402. void DigestString();
  14403.  
  14404. void main(int argc, char *argv[])
  14405. {
  14406.     printf("%s\n\n", MDxGetVersion());
  14407.  
  14408.     if( argc > 1 )
  14409.         DigestFile( argv[1] );
  14410.     else    
  14411.         DigestString();
  14412.  
  14413. }
  14414.  
  14415. /*
  14416.     I use the 'chunk' method for processing files not because of
  14417.     limitations of my dll, but think what would happen if you
  14418.     tried to load an entire cd image into memory.
  14419. */
  14420. void DigestFile( char *szFName )
  14421. {
  14422.     FILE *file;
  14423.     void *lpData;
  14424.     long flen, mlen;
  14425.     MDxSum mdDataSum;
  14426.     MDxSum md4DataSum;
  14427.  
  14428.     // the 64 is for padding purposes
  14429.     lpData = malloc( READLEN + 64 );
  14430.     
  14431.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  14432.  
  14433.     file = fopen( szFName, "rb" );
  14434.     if( file == NULL )
  14435.     {
  14436.         printf("ERROR: File not found.\n");
  14437.         return;
  14438.     }
  14439.     
  14440.     MDxInit( &mdDataSum );
  14441.     MDxInit( &md4DataSum );
  14442.     
  14443.     fseek( file, 0, SEEK_END );
  14444.     //Get the file length
  14445.     flen = mlen = ftell( file );
  14446.     fseek( file, 0, SEEK_SET );
  14447.     
  14448.     // When it takes a while to process a large file,
  14449.     // remember that for each chunk it has to run 
  14450.     // through the main translation loop 16384 times!
  14451.         
  14452.     printf("Processing %ld byte file: .", flen );
  14453.     
  14454.     while( flen > READLEN )
  14455.     {
  14456.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  14457.         {
  14458.             printf("READ ERROR!\n");
  14459.             return;
  14460.         }
  14461.         MD5Translate( lpData, READLEN, &mdDataSum );
  14462.         MD4Translate( lpData, READLEN, &md4DataSum );
  14463.         flen -= READLEN;
  14464.         printf(".");
  14465.     }
  14466.  
  14467.     if (fread( lpData, 1, flen, file ) != flen)
  14468.     {
  14469.         printf("READ ERROR!\n");
  14470.         return;
  14471.     }
  14472.     // This is why I added the new argument to MDxPad
  14473.     // So we can pass the length of the data AND the
  14474.     // Total length of the message
  14475.     // Also it now returns the # of padding bytes added,
  14476.     // this is for files that are an exact multiple of the chunk
  14477.     // length. (Otherwise the padding isn't Translated)
  14478.     flen += MDxPad( lpData, flen, mlen );
  14479.     MD5Translate( lpData, flen, &mdDataSum );    
  14480.     MD4Translate( lpData, flen, &md4DataSum );
  14481.  
  14482.     // New step necessary because of the 'chunking' method
  14483.     MDxFinalize( &mdDataSum );
  14484.     MDxFinalize( &md4DataSum );
  14485.     
  14486.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14487.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14488.     fclose(file);
  14489.         
  14490. }
  14491.  
  14492. void DigestString()
  14493. {
  14494.     
  14495.     //For our demo purposes, no strings bigger than 1024 :)
  14496.     unsigned char lpData[1024] = "";
  14497.     long len = 0;
  14498.     MDxSum mdDataSum;
  14499.  
  14500.     printf("Enter the string to digest: ");
  14501.     scanf("%s", &lpData );
  14502.     len = strlen(lpData);
  14503.     
  14504.     // Have to do this before the Padding...well...it's best anyway;)
  14505.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14506.     
  14507.     // For the strings, we're gonna pad and digest the string
  14508.     // in one pass.
  14509.     MDxInit( &mdDataSum );
  14510.     MDxPad( lpData, len, len );
  14511.     
  14512.     MD5Translate( lpData, len, &mdDataSum );
  14513.         // New step necessary because of the 'chunking' method
  14514.         MDxFinalize( &mdDataSum );
  14515.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14516.     
  14517.     MDxInit( &mdDataSum );
  14518.     MD4Translate( lpData, len, &mdDataSum );    
  14519.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14520.  
  14521.     return;
  14522. }
  14523.  
  14524.  
  14525. -------------- Include
  14526.  
  14527. #ifndef __windows_h__
  14528.         typedef unsigned long DWORD;
  14529.         #define STDCALL _stdcall
  14530. #endif
  14531.  
  14532. typedef struct 
  14533. {
  14534.     DWORD dwSum[4];
  14535. }MDxSum;
  14536.  
  14537. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14538. void STDCALL MDxInit( MDxSum * );
  14539. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14540. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  14541. const char * STDCALL MDxGetVersion();
  14542. void STDCALL MDxFinalize( MDxSum * );
  14543.  
  14544.  
  14545.  
  14546. #include "mdx.h"
  14547. #include <stdlib.h>
  14548. #include <stdio.h>
  14549. #include <string.h>
  14550.  
  14551. // READLEN % 64 must = 0
  14552. #define READLEN    1048576L // 2^20, 1MB
  14553.  
  14554. void DigestFile( char * );
  14555. void DigestString();
  14556.  
  14557. void main(int argc, char *argv[])
  14558. {
  14559.     printf("%s\n\n", MDxGetVersion());
  14560.  
  14561.     if( argc > 1 )
  14562.         DigestFile( argv[1] );
  14563.     else    
  14564.         DigestString();
  14565.  
  14566. }
  14567.  
  14568. /*
  14569.     I use the 'chunk' method for processing files not because of
  14570.     limitations of my dll, but think what would happen if you
  14571.     tried to load an entire cd image into memory.
  14572. */
  14573. void DigestFile( char *szFName )
  14574. {
  14575.     FILE *file;
  14576.     void *lpData;
  14577.     long flen, mlen;
  14578.     MDxSum mdDataSum;
  14579.     MDxSum md4DataSum;
  14580.  
  14581.     // the 64 is for padding purposes
  14582.     lpData = malloc( READLEN + 64 );
  14583.     
  14584.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  14585.  
  14586.     file = fopen( szFName, "rb" );
  14587.     if( file == NULL )
  14588.     {
  14589.         printf("ERROR: File not found.\n");
  14590.         return;
  14591.     }
  14592.     
  14593.     MDxInit( &mdDataSum );
  14594.     MDxInit( &md4DataSum );
  14595.     
  14596.     fseek( file, 0, SEEK_END );
  14597.     //Get the file length
  14598.     flen = mlen = ftell( file );
  14599.     fseek( file, 0, SEEK_SET );
  14600.     
  14601.     // When it takes a while to process a large file,
  14602.     // remember that for each chunk it has to run 
  14603.     // through the main translation loop 16384 times!
  14604.         
  14605.     printf("Processing %ld byte file: .", flen );
  14606.     
  14607.     while( flen > READLEN )
  14608.     {
  14609.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  14610.         {
  14611.             printf("READ ERROR!\n");
  14612.             return;
  14613.         }
  14614.         MD5Translate( lpData, READLEN, &mdDataSum );
  14615.         MD4Translate( lpData, READLEN, &md4DataSum );
  14616.         flen -= READLEN;
  14617.         printf(".");
  14618.     }
  14619.  
  14620.     if (fread( lpData, 1, flen, file ) != flen)
  14621.     {
  14622.         printf("READ ERROR!\n");
  14623.         return;
  14624.     }
  14625.     // This is why I added the new argument to MDxPad
  14626.     // So we can pass the length of the data AND the
  14627.     // Total length of the message
  14628.     // Also it now returns the # of padding bytes added,
  14629.     // this is for files that are an exact multiple of the chunk
  14630.     // length. (Otherwise the padding isn't Translated)
  14631.     flen += MDxPad( lpData, flen, mlen );
  14632.     MD5Translate( lpData, flen, &mdDataSum );    
  14633.     MD4Translate( lpData, flen, &md4DataSum );
  14634.  
  14635.     // New step necessary because of the 'chunking' method
  14636.     MDxFinalize( &mdDataSum );
  14637.     MDxFinalize( &md4DataSum );
  14638.     
  14639.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14640.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14641.     fclose(file);
  14642.         
  14643. }
  14644.  
  14645. void DigestString()
  14646. {
  14647.     
  14648.     //For our demo purposes, no strings bigger than 1024 :)
  14649.     unsigned char lpData[1024] = "";
  14650.     long len = 0;
  14651.     MDxSum mdDataSum;
  14652.  
  14653.     printf("Enter the string to digest: ");
  14654.     scanf("%s", &lpData );
  14655.     len = strlen(lpData);
  14656.     
  14657.     // Have to do this before the Padding...well...it's best anyway;)
  14658.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14659.     
  14660.     // For the strings, we're gonna pad and digest the string
  14661.     // in one pass.
  14662.     MDxInit( &mdDataSum );
  14663.     MDxPad( lpData, len, len );
  14664.     
  14665.     MD5Translate( lpData, len, &mdDataSum );
  14666.         // New step necessary because of the 'chunking' method
  14667.         MDxFinalize( &mdDataSum );
  14668.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14669.     
  14670.     MDxInit( &mdDataSum );
  14671.     MD4Translate( lpData, len, &mdDataSum );    
  14672.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14673.  
  14674.     return;
  14675. }
  14676.  
  14677.  
  14678. -------------- Include
  14679.  
  14680. #ifndef __windows_h__
  14681.         typedef unsigned long DWORD;
  14682.         #define STDCALL _stdcall
  14683. #endif
  14684.  
  14685. typedef struct 
  14686. {
  14687.     DWORD dwSum[4];
  14688. }MDxSum;
  14689.  
  14690. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14691. void STDCALL MDxInit( MDxSum * );
  14692. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14693. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  14694. const char * STDCALL MDxGetVersion();
  14695. void STDCALL MDxFinalize( MDxSum * );
  14696.  
  14697.  
  14698.  
  14699. #include "mdx.h"
  14700. #include <stdlib.h>
  14701. #include <stdio.h>
  14702. #include <string.h>
  14703.  
  14704. // READLEN % 64 must = 0
  14705. #define READLEN    1048576L // 2^20, 1MB
  14706.  
  14707. void DigestFile( char * );
  14708. void DigestString();
  14709.  
  14710. void main(int argc, char *argv[])
  14711. {
  14712.     printf("%s\n\n", MDxGetVersion());
  14713.  
  14714.     if( argc > 1 )
  14715.         DigestFile( argv[1] );
  14716.     else    
  14717.         DigestString();
  14718.  
  14719. }
  14720.  
  14721. /*
  14722.     I use the 'chunk' method for processing files not because of
  14723.     limitations of my dll, but think what would happen if you
  14724.     tried to load an entire cd image into memory.
  14725. */
  14726. void DigestFile( char *szFName )
  14727. {
  14728.     FILE *file;
  14729.     void *lpData;
  14730.     long flen, mlen;
  14731.     MDxSum mdDataSum;
  14732.     MDxSum md4DataSum;
  14733.  
  14734.     // the 64 is for padding purposes
  14735.     lpData = malloc( READLEN + 64 );
  14736.     
  14737.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  14738.  
  14739.     file = fopen( szFName, "rb" );
  14740.     if( file == NULL )
  14741.     {
  14742.         printf("ERROR: File not found.\n");
  14743.         return;
  14744.     }
  14745.     
  14746.     MDxInit( &mdDataSum );
  14747.     MDxInit( &md4DataSum );
  14748.     
  14749.     fseek( file, 0, SEEK_END );
  14750.     //Get the file length
  14751.     flen = mlen = ftell( file );
  14752.     fseek( file, 0, SEEK_SET );
  14753.     
  14754.     // When it takes a while to process a large file,
  14755.     // remember that for each chunk it has to run 
  14756.     // through the main translation loop 16384 times!
  14757.         
  14758.     printf("Processing %ld byte file: .", flen );
  14759.     
  14760.     while( flen > READLEN )
  14761.     {
  14762.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  14763.         {
  14764.             printf("READ ERROR!\n");
  14765.             return;
  14766.         }
  14767.         MD5Translate( lpData, READLEN, &mdDataSum );
  14768.         MD4Translate( lpData, READLEN, &md4DataSum );
  14769.         flen -= READLEN;
  14770.         printf(".");
  14771.     }
  14772.  
  14773.     if (fread( lpData, 1, flen, file ) != flen)
  14774.     {
  14775.         printf("READ ERROR!\n");
  14776.         return;
  14777.     }
  14778.     // This is why I added the new argument to MDxPad
  14779.     // So we can pass the length of the data AND the
  14780.     // Total length of the message
  14781.     // Also it now returns the # of padding bytes added,
  14782.     // this is for files that are an exact multiple of the chunk
  14783.     // length. (Otherwise the padding isn't Translated)
  14784.     flen += MDxPad( lpData, flen, mlen );
  14785.     MD5Translate( lpData, flen, &mdDataSum );    
  14786.     MD4Translate( lpData, flen, &md4DataSum );
  14787.  
  14788.     // New step necessary because of the 'chunking' method
  14789.     MDxFinalize( &mdDataSum );
  14790.     MDxFinalize( &md4DataSum );
  14791.     
  14792.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14793.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14794.     fclose(file);
  14795.         
  14796. }
  14797.  
  14798. void DigestString()
  14799. {
  14800.     
  14801.     //For our demo purposes, no strings bigger than 1024 :)
  14802.     unsigned char lpData[1024] = "";
  14803.     long len = 0;
  14804.     MDxSum mdDataSum;
  14805.  
  14806.     printf("Enter the string to digest: ");
  14807.     scanf("%s", &lpData );
  14808.     len = strlen(lpData);
  14809.     
  14810.     // Have to do this before the Padding...well...it's best anyway;)
  14811.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14812.     
  14813.     // For the strings, we're gonna pad and digest the string
  14814.     // in one pass.
  14815.     MDxInit( &mdDataSum );
  14816.     MDxPad( lpData, len, len );
  14817.     
  14818.     MD5Translate( lpData, len, &mdDataSum );
  14819.         // New step necessary because of the 'chunking' method
  14820.         MDxFinalize( &mdDataSum );
  14821.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14822.     
  14823.     MDxInit( &mdDataSum );
  14824.     MD4Translate( lpData, len, &mdDataSum );    
  14825.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14826.  
  14827.     return;
  14828. }
  14829.  
  14830.  
  14831. -------------- Include
  14832.  
  14833. #ifndef __windows_h__
  14834.         typedef unsigned long DWORD;
  14835.         #define STDCALL _stdcall
  14836. #endif
  14837.  
  14838. typedef struct 
  14839. {
  14840.     DWORD dwSum[4];
  14841. }MDxSum;
  14842.  
  14843. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14844. void STDCALL MDxInit( MDxSum * );
  14845. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14846. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  14847. const char * STDCALL MDxGetVersion();
  14848. void STDCALL MDxFinalize( MDxSum * );
  14849.  
  14850.  
  14851.  
  14852. #include "mdx.h"
  14853. #include <stdlib.h>
  14854. #include <stdio.h>
  14855. #include <string.h>
  14856.  
  14857. // READLEN % 64 must = 0
  14858. #define READLEN    1048576L // 2^20, 1MB
  14859.  
  14860. void DigestFile( char * );
  14861. void DigestString();
  14862.  
  14863. void main(int argc, char *argv[])
  14864. {
  14865.     printf("%s\n\n", MDxGetVersion());
  14866.  
  14867.     if( argc > 1 )
  14868.         DigestFile( argv[1] );
  14869.     else    
  14870.         DigestString();
  14871.  
  14872. }
  14873.  
  14874. /*
  14875.     I use the 'chunk' method for processing files not because of
  14876.     limitations of my dll, but think what would happen if you
  14877.     tried to load an entire cd image into memory.
  14878. */
  14879. void DigestFile( char *szFName )
  14880. {
  14881.     FILE *file;
  14882.     void *lpData;
  14883.     long flen, mlen;
  14884.     MDxSum mdDataSum;
  14885.     MDxSum md4DataSum;
  14886.  
  14887.     // the 64 is for padding purposes
  14888.     lpData = malloc( READLEN + 64 );
  14889.     
  14890.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  14891.  
  14892.     file = fopen( szFName, "rb" );
  14893.     if( file == NULL )
  14894.     {
  14895.         printf("ERROR: File not found.\n");
  14896.         return;
  14897.     }
  14898.     
  14899.     MDxInit( &mdDataSum );
  14900.     MDxInit( &md4DataSum );
  14901.     
  14902.     fseek( file, 0, SEEK_END );
  14903.     //Get the file length
  14904.     flen = mlen = ftell( file );
  14905.     fseek( file, 0, SEEK_SET );
  14906.     
  14907.     // When it takes a while to process a large file,
  14908.     // remember that for each chunk it has to run 
  14909.     // through the main translation loop 16384 times!
  14910.         
  14911.     printf("Processing %ld byte file: .", flen );
  14912.     
  14913.     while( flen > READLEN )
  14914.     {
  14915.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  14916.         {
  14917.             printf("READ ERROR!\n");
  14918.             return;
  14919.         }
  14920.         MD5Translate( lpData, READLEN, &mdDataSum );
  14921.         MD4Translate( lpData, READLEN, &md4DataSum );
  14922.         flen -= READLEN;
  14923.         printf(".");
  14924.     }
  14925.  
  14926.     if (fread( lpData, 1, flen, file ) != flen)
  14927.     {
  14928.         printf("READ ERROR!\n");
  14929.         return;
  14930.     }
  14931.     // This is why I added the new argument to MDxPad
  14932.     // So we can pass the length of the data AND the
  14933.     // Total length of the message
  14934.     // Also it now returns the # of padding bytes added,
  14935.     // this is for files that are an exact multiple of the chunk
  14936.     // length. (Otherwise the padding isn't Translated)
  14937.     flen += MDxPad( lpData, flen, mlen );
  14938.     MD5Translate( lpData, flen, &mdDataSum );    
  14939.     MD4Translate( lpData, flen, &md4DataSum );
  14940.  
  14941.     // New step necessary because of the 'chunking' method
  14942.     MDxFinalize( &mdDataSum );
  14943.     MDxFinalize( &md4DataSum );
  14944.     
  14945.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  14946.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14947.     fclose(file);
  14948.         
  14949. }
  14950.  
  14951. void DigestString()
  14952. {
  14953.     
  14954.     //For our demo purposes, no strings bigger than 1024 :)
  14955.     unsigned char lpData[1024] = "";
  14956.     long len = 0;
  14957.     MDxSum mdDataSum;
  14958.  
  14959.     printf("Enter the string to digest: ");
  14960.     scanf("%s", &lpData );
  14961.     len = strlen(lpData);
  14962.     
  14963.     // Have to do this before the Padding...well...it's best anyway;)
  14964.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  14965.     
  14966.     // For the strings, we're gonna pad and digest the string
  14967.     // in one pass.
  14968.     MDxInit( &mdDataSum );
  14969.     MDxPad( lpData, len, len );
  14970.     
  14971.     MD5Translate( lpData, len, &mdDataSum );
  14972.         // New step necessary because of the 'chunking' method
  14973.         MDxFinalize( &mdDataSum );
  14974.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14975.     
  14976.     MDxInit( &mdDataSum );
  14977.     MD4Translate( lpData, len, &mdDataSum );    
  14978.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  14979.  
  14980.     return;
  14981. }
  14982.  
  14983.  
  14984. -------------- Include
  14985.  
  14986. #ifndef __windows_h__
  14987.         typedef unsigned long DWORD;
  14988.         #define STDCALL _stdcall
  14989. #endif
  14990.  
  14991. typedef struct 
  14992. {
  14993.     DWORD dwSum[4];
  14994. }MDxSum;
  14995.  
  14996. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  14997. void STDCALL MDxInit( MDxSum * );
  14998. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  14999. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15000. const char * STDCALL MDxGetVersion();
  15001. void STDCALL MDxFinalize( MDxSum * );
  15002.  
  15003.  
  15004.  
  15005. #include "mdx.h"
  15006. #include <stdlib.h>
  15007. #include <stdio.h>
  15008. #include <string.h>
  15009.  
  15010. // READLEN % 64 must = 0
  15011. #define READLEN    1048576L // 2^20, 1MB
  15012.  
  15013. void DigestFile( char * );
  15014. void DigestString();
  15015.  
  15016. void main(int argc, char *argv[])
  15017. {
  15018.     printf("%s\n\n", MDxGetVersion());
  15019.  
  15020.     if( argc > 1 )
  15021.         DigestFile( argv[1] );
  15022.     else    
  15023.         DigestString();
  15024.  
  15025. }
  15026.  
  15027. /*
  15028.     I use the 'chunk' method for processing files not because of
  15029.     limitations of my dll, but think what would happen if you
  15030.     tried to load an entire cd image into memory.
  15031. */
  15032. void DigestFile( char *szFName )
  15033. {
  15034.     FILE *file;
  15035.     void *lpData;
  15036.     long flen, mlen;
  15037.     MDxSum mdDataSum;
  15038.     MDxSum md4DataSum;
  15039.  
  15040.     // the 64 is for padding purposes
  15041.     lpData = malloc( READLEN + 64 );
  15042.     
  15043.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15044.  
  15045.     file = fopen( szFName, "rb" );
  15046.     if( file == NULL )
  15047.     {
  15048.         printf("ERROR: File not found.\n");
  15049.         return;
  15050.     }
  15051.     
  15052.     MDxInit( &mdDataSum );
  15053.     MDxInit( &md4DataSum );
  15054.     
  15055.     fseek( file, 0, SEEK_END );
  15056.     //Get the file length
  15057.     flen = mlen = ftell( file );
  15058.     fseek( file, 0, SEEK_SET );
  15059.     
  15060.     // When it takes a while to process a large file,
  15061.     // remember that for each chunk it has to run 
  15062.     // through the main translation loop 16384 times!
  15063.         
  15064.     printf("Processing %ld byte file: .", flen );
  15065.     
  15066.     while( flen > READLEN )
  15067.     {
  15068.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15069.         {
  15070.             printf("READ ERROR!\n");
  15071.             return;
  15072.         }
  15073.         MD5Translate( lpData, READLEN, &mdDataSum );
  15074.         MD4Translate( lpData, READLEN, &md4DataSum );
  15075.         flen -= READLEN;
  15076.         printf(".");
  15077.     }
  15078.  
  15079.     if (fread( lpData, 1, flen, file ) != flen)
  15080.     {
  15081.         printf("READ ERROR!\n");
  15082.         return;
  15083.     }
  15084.     // This is why I added the new argument to MDxPad
  15085.     // So we can pass the length of the data AND the
  15086.     // Total length of the message
  15087.     // Also it now returns the # of padding bytes added,
  15088.     // this is for files that are an exact multiple of the chunk
  15089.     // length. (Otherwise the padding isn't Translated)
  15090.     flen += MDxPad( lpData, flen, mlen );
  15091.     MD5Translate( lpData, flen, &mdDataSum );    
  15092.     MD4Translate( lpData, flen, &md4DataSum );
  15093.  
  15094.     // New step necessary because of the 'chunking' method
  15095.     MDxFinalize( &mdDataSum );
  15096.     MDxFinalize( &md4DataSum );
  15097.     
  15098.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  15099.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15100.     fclose(file);
  15101.         
  15102. }
  15103.  
  15104. void DigestString()
  15105. {
  15106.     
  15107.     //For our demo purposes, no strings bigger than 1024 :)
  15108.     unsigned char lpData[1024] = "";
  15109.     long len = 0;
  15110.     MDxSum mdDataSum;
  15111.  
  15112.     printf("Enter the string to digest: ");
  15113.     scanf("%s", &lpData );
  15114.     len = strlen(lpData);
  15115.     
  15116.     // Have to do this before the Padding...well...it's best anyway;)
  15117.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  15118.     
  15119.     // For the strings, we're gonna pad and digest the string
  15120.     // in one pass.
  15121.     MDxInit( &mdDataSum );
  15122.     MDxPad( lpData, len, len );
  15123.     
  15124.     MD5Translate( lpData, len, &mdDataSum );
  15125.         // New step necessary because of the 'chunking' method
  15126.         MDxFinalize( &mdDataSum );
  15127.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15128.     
  15129.     MDxInit( &mdDataSum );
  15130.     MD4Translate( lpData, len, &mdDataSum );    
  15131.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15132.  
  15133.     return;
  15134. }
  15135.  
  15136.  
  15137. -------------- Include
  15138.  
  15139. #ifndef __windows_h__
  15140.         typedef unsigned long DWORD;
  15141.         #define STDCALL _stdcall
  15142. #endif
  15143.  
  15144. typedef struct 
  15145. {
  15146.     DWORD dwSum[4];
  15147. }MDxSum;
  15148.  
  15149. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  15150. void STDCALL MDxInit( MDxSum * );
  15151. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  15152. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15153. const char * STDCALL MDxGetVersion();
  15154. void STDCALL MDxFinalize( MDxSum * );
  15155.  
  15156.  
  15157.  
  15158. #include "mdx.h"
  15159. #include <stdlib.h>
  15160. #include <stdio.h>
  15161. #include <string.h>
  15162.  
  15163. // READLEN % 64 must = 0
  15164. #define READLEN    1048576L // 2^20, 1MB
  15165.  
  15166. void DigestFile( char * );
  15167. void DigestString();
  15168.  
  15169. void main(int argc, char *argv[])
  15170. {
  15171.     printf("%s\n\n", MDxGetVersion());
  15172.  
  15173.     if( argc > 1 )
  15174.         DigestFile( argv[1] );
  15175.     else    
  15176.         DigestString();
  15177.  
  15178. }
  15179.  
  15180. /*
  15181.     I use the 'chunk' method for processing files not because of
  15182.     limitations of my dll, but think what would happen if you
  15183.     tried to load an entire cd image into memory.
  15184. */
  15185. void DigestFile( char *szFName )
  15186. {
  15187.     FILE *file;
  15188.     void *lpData;
  15189.     long flen, mlen;
  15190.     MDxSum mdDataSum;
  15191.     MDxSum md4DataSum;
  15192.  
  15193.     // the 64 is for padding purposes
  15194.     lpData = malloc( READLEN + 64 );
  15195.     
  15196.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15197.  
  15198.     file = fopen( szFName, "rb" );
  15199.     if( file == NULL )
  15200.     {
  15201.         printf("ERROR: File not found.\n");
  15202.         return;
  15203.     }
  15204.     
  15205.     MDxInit( &mdDataSum );
  15206.     MDxInit( &md4DataSum );
  15207.     
  15208.     fseek( file, 0, SEEK_END );
  15209.     //Get the file length
  15210.     flen = mlen = ftell( file );
  15211.     fseek( file, 0, SEEK_SET );
  15212.     
  15213.     // When it takes a while to process a large file,
  15214.     // remember that for each chunk it has to run 
  15215.     // through the main translation loop 16384 times!
  15216.         
  15217.     printf("Processing %ld byte file: .", flen );
  15218.     
  15219.     while( flen > READLEN )
  15220.     {
  15221.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15222.         {
  15223.             printf("READ ERROR!\n");
  15224.             return;
  15225.         }
  15226.         MD5Translate( lpData, READLEN, &mdDataSum );
  15227.         MD4Translate( lpData, READLEN, &md4DataSum );
  15228.         flen -= READLEN;
  15229.         printf(".");
  15230.     }
  15231.  
  15232.     if (fread( lpData, 1, flen, file ) != flen)
  15233.     {
  15234.         printf("READ ERROR!\n");
  15235.         return;
  15236.     }
  15237.     // This is why I added the new argument to MDxPad
  15238.     // So we can pass the length of the data AND the
  15239.     // Total length of the message
  15240.     // Also it now returns the # of padding bytes added,
  15241.     // this is for files that are an exact multiple of the chunk
  15242.     // length. (Otherwise the padding isn't Translated)
  15243.     flen += MDxPad( lpData, flen, mlen );
  15244.     MD5Translate( lpData, flen, &mdDataSum );    
  15245.     MD4Translate( lpData, flen, &md4DataSum );
  15246.  
  15247.     // New step necessary because of the 'chunking' method
  15248.     MDxFinalize( &mdDataSum );
  15249.     MDxFinalize( &md4DataSum );
  15250.     
  15251.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  15252.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15253.     fclose(file);
  15254.         
  15255. }
  15256.  
  15257. void DigestString()
  15258. {
  15259.     
  15260.     //For our demo purposes, no strings bigger than 1024 :)
  15261.     unsigned char lpData[1024] = "";
  15262.     long len = 0;
  15263.     MDxSum mdDataSum;
  15264.  
  15265.     printf("Enter the string to digest: ");
  15266.     scanf("%s", &lpData );
  15267.     len = strlen(lpData);
  15268.     
  15269.     // Have to do this before the Padding...well...it's best anyway;)
  15270.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  15271.     
  15272.     // For the strings, we're gonna pad and digest the string
  15273.     // in one pass.
  15274.     MDxInit( &mdDataSum );
  15275.     MDxPad( lpData, len, len );
  15276.     
  15277.     MD5Translate( lpData, len, &mdDataSum );
  15278.         // New step necessary because of the 'chunking' method
  15279.         MDxFinalize( &mdDataSum );
  15280.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15281.     
  15282.     MDxInit( &mdDataSum );
  15283.     MD4Translate( lpData, len, &mdDataSum );    
  15284.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15285.  
  15286.     return;
  15287. }
  15288.  
  15289.  
  15290. -------------- Include
  15291.  
  15292. #ifndef __windows_h__
  15293.         typedef unsigned long DWORD;
  15294.         #define STDCALL _stdcall
  15295. #endif
  15296.  
  15297. typedef struct 
  15298. {
  15299.     DWORD dwSum[4];
  15300. }MDxSum;
  15301.  
  15302. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  15303. void STDCALL MDxInit( MDxSum * );
  15304. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  15305. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15306. const char * STDCALL MDxGetVersion();
  15307. void STDCALL MDxFinalize( MDxSum * );
  15308.  
  15309.  
  15310. #include "mdx.h"
  15311. #include <stdlib.h>
  15312. #include <stdio.h>
  15313. #include <string.h>
  15314.  
  15315. // READLEN % 64 must = 0
  15316. #define READLEN    1048576L // 2^20, 1MB
  15317.  
  15318. void DigestFile( char * );
  15319. void DigestString();
  15320.  
  15321. void main(int argc, char *argv[])
  15322. {
  15323.     printf("%s\n\n", MDxGetVersion());
  15324.  
  15325.     if( argc > 1 )
  15326.         DigestFile( argv[1] );
  15327.     else    
  15328.         DigestString();
  15329.  
  15330. }
  15331.  
  15332. /*
  15333.     I use the 'chunk' method for processing files not because of
  15334.     limitations of my dll, but think what would happen if you
  15335.     tried to load an entire cd image into memory.
  15336. */
  15337. void DigestFile( char *szFName )
  15338. {
  15339.     FILE *file;
  15340.     void *lpData;
  15341.     long flen, mlen;
  15342.     MDxSum mdDataSum;
  15343.     MDxSum md4DataSum;
  15344.  
  15345.     // the 64 is for padding purposes
  15346.     lpData = malloc( READLEN + 64 );
  15347.     
  15348.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15349.  
  15350.     file = fopen( szFName, "rb" );
  15351.     if( file == NULL )
  15352.     {
  15353.         printf("ERROR: File not found.\n");
  15354.         return;
  15355.     }
  15356.     
  15357.     MDxInit( &mdDataSum );
  15358.     MDxInit( &md4DataSum );
  15359.     
  15360.     fseek( file, 0, SEEK_END );
  15361.     //Get the file length
  15362.     flen = mlen = ftell( file );
  15363.     fseek( file, 0, SEEK_SET );
  15364.     
  15365.     // When it takes a while to process a large file,
  15366.     // remember that for each chunk it has to run 
  15367.     // through the main translation loop 16384 times!
  15368.         
  15369.     printf("Processing %ld byte file: .", flen );
  15370.     
  15371.     while( flen > READLEN )
  15372.     {
  15373.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15374.         {
  15375.             printf("READ ERROR!\n");
  15376.             return;
  15377.         }
  15378.         MD5Translate( lpData, READLEN, &mdDataSum );
  15379.         MD4Translate( lpData, READLEN, &md4DataSum );
  15380.         flen -= READLEN;
  15381.         printf(".");
  15382.     }
  15383.  
  15384.     if (fread( lpData, 1, flen, file ) != flen)
  15385.     {
  15386.         printf("READ ERROR!\n");
  15387.         return;
  15388.     }
  15389.     // This is why I added the new argument to MDxPad
  15390.     // So we can pass the length of the data AND the
  15391.     // Total length of the message
  15392.     // Also it now returns the # of padding bytes added,
  15393.     // this is for files that are an exact multiple of the chunk
  15394.     // length. (Otherwise the padding isn't Translated)
  15395.     flen += MDxPad( lpData, flen, mlen );
  15396.     MD5Translate( lpData, flen, &mdDataSum );    
  15397.     MD4Translate( lpData, flen, &md4DataSum );
  15398.  
  15399.     // New step necessary because of the 'chunking' method
  15400.     MDxFinalize( &mdDataSum );
  15401.     MDxFinalize( &md4DataSum );
  15402.     
  15403.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  15404.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15405.     fclose(file);
  15406.         
  15407. }
  15408.  
  15409. void DigestString()
  15410. {
  15411.     
  15412.     //For our demo purposes, no strings bigger than 1024 :)
  15413.     unsigned char lpData[1024] = "";
  15414.     long len = 0;
  15415.     MDxSum mdDataSum;
  15416.  
  15417.     printf("Enter the string to digest: ");
  15418.     scanf("%s", &lpData );
  15419.     len = strlen(lpData);
  15420.     
  15421.     // Have to do this before the Padding...well...it's best anyway;)
  15422.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  15423.     
  15424.     // For the strings, we're gonna pad and digest the string
  15425.     // in one pass.
  15426.     MDxInit( &mdDataSum );
  15427.     MDxPad( lpData, len, len );
  15428.     
  15429.     MD5Translate( lpData, len, &mdDataSum );
  15430.         // New step necessary because of the 'chunking' method
  15431.         MDxFinalize( &mdDataSum );
  15432.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15433.     
  15434.     MDxInit( &mdDataSum );
  15435.     MD4Translate( lpData, len, &mdDataSum );    
  15436.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15437.  
  15438.     return;
  15439. }
  15440.  
  15441.  
  15442. -------------- Include
  15443.  
  15444. #ifndef __windows_h__
  15445.         typedef unsigned long DWORD;
  15446.         #define STDCALL _stdcall
  15447. #endif
  15448.  
  15449. typedef struct 
  15450. {
  15451.     DWORD dwSum[4];
  15452. }MDxSum;
  15453.  
  15454. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  15455. void STDCALL MDxInit( MDxSum * );
  15456. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  15457. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15458. const char * STDCALL MDxGetVersion();
  15459. void STDCALL MDxFinalize( MDxSum * );
  15460.  
  15461.  
  15462. #include "mdx.h"
  15463. #include <stdlib.h>
  15464. #include <stdio.h>
  15465. #include <string.h>
  15466.  
  15467. // READLEN % 64 must = 0
  15468. #define READLEN    1048576L // 2^20, 1MB
  15469.  
  15470. void DigestFile( char * );
  15471. void DigestString();
  15472.  
  15473. void main(int argc, char *argv[])
  15474. {
  15475.     printf("%s\n\n", MDxGetVersion());
  15476.  
  15477.     if( argc > 1 )
  15478.         DigestFile( argv[1] );
  15479.     else    
  15480.         DigestString();
  15481.  
  15482. }
  15483.  
  15484. /*
  15485.     I use the 'chunk' method for processing files not because of
  15486.     limitations of my dll, but think what would happen if you
  15487.     tried to load an entire cd image into memory.
  15488. */
  15489. void DigestFile( char *szFName )
  15490. {
  15491.     FILE *file;
  15492.     void *lpData;
  15493.     long flen, mlen;
  15494.     MDxSum mdDataSum;
  15495.     MDxSum md4DataSum;
  15496.  
  15497.     // the 64 is for padding purposes
  15498.     lpData = malloc( READLEN + 64 );
  15499.     
  15500.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15501.  
  15502.     file = fopen( szFName, "rb" );
  15503.     if( file == NULL )
  15504.     {
  15505.         printf("ERROR: File not found.\n");
  15506.         return;
  15507.     }
  15508.     
  15509.     MDxInit( &mdDataSum );
  15510.     MDxInit( &md4DataSum );
  15511.     
  15512.     fseek( file, 0, SEEK_END );
  15513.     //Get the file length
  15514.     flen = mlen = ftell( file );
  15515.     fseek( file, 0, SEEK_SET );
  15516.     
  15517.     // When it takes a while to process a large file,
  15518.     // remember that for each chunk it has to run 
  15519.     // through the main translation loop 16384 times!
  15520.         
  15521.     printf("Processing %ld byte file: .", flen );
  15522.     
  15523.     while( flen > READLEN )
  15524.     {
  15525.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15526.         {
  15527.             printf("READ ERROR!\n");
  15528.             return;
  15529.         }
  15530.         MD5Translate( lpData, READLEN, &mdDataSum );
  15531.         MD4Translate( lpData, READLEN, &md4DataSum );
  15532.         flen -= READLEN;
  15533.         printf(".");
  15534.     }
  15535.  
  15536.     if (fread( lpData, 1, flen, file ) != flen)
  15537.     {
  15538.         printf("READ ERROR!\n");
  15539.         return;
  15540.     }
  15541.     // This is why I added the new argument to MDxPad
  15542.     // So we can pass the length of the data AND the
  15543.     // Total length of the message
  15544.     // Also it now returns the # of padding bytes added,
  15545.     // this is for files that are an exact multiple of the chunk
  15546.     // length. (Otherwise the padding isn't Translated)
  15547.     flen += MDxPad( lpData, flen, mlen );
  15548.     MD5Translate( lpData, flen, &mdDataSum );    
  15549.     MD4Translate( lpData, flen, &md4DataSum );
  15550.  
  15551.     // New step necessary because of the 'chunking' method
  15552.     MDxFinalize( &mdDataSum );
  15553.     MDxFinalize( &md4DataSum );
  15554.     
  15555.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  15556.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15557.     fclose(file);
  15558.         
  15559. }
  15560.  
  15561. void DigestString()
  15562. {
  15563.     
  15564.     //For our demo purposes, no strings bigger than 1024 :)
  15565.     unsigned char lpData[1024] = "";
  15566.     long len = 0;
  15567.     MDxSum mdDataSum;
  15568.  
  15569.     printf("Enter the string to digest: ");
  15570.     scanf("%s", &lpData );
  15571.     len = strlen(lpData);
  15572.     
  15573.     // Have to do this before the Padding...well...it's best anyway;)
  15574.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  15575.     
  15576.     // For the strings, we're gonna pad and digest the string
  15577.     // in one pass.
  15578.     MDxInit( &mdDataSum );
  15579.     MDxPad( lpData, len, len );
  15580.     
  15581.     MD5Translate( lpData, len, &mdDataSum );
  15582.         // New step necessary because of the 'chunking' method
  15583.         MDxFinalize( &mdDataSum );
  15584.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15585.     
  15586.     MDxInit( &mdDataSum );
  15587.     MD4Translate( lpData, len, &mdDataSum );    
  15588.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15589.  
  15590.     return;
  15591. }
  15592.  
  15593.  
  15594. -------------- Include
  15595.  
  15596. #ifndef __windows_h__
  15597.         typedef unsigned long DWORD;
  15598.         #define STDCALL _stdcall
  15599. #endif
  15600.  
  15601. typedef struct 
  15602. {
  15603.     DWORD dwSum[4];
  15604. }MDxSum;
  15605.  
  15606. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  15607. void STDCALL MDxInit( MDxSum * );
  15608. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  15609. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15610. const char * STDCALL MDxGetVersion();
  15611. void STDCALL MDxFinalize( MDxSum * );
  15612.  
  15613. #include "mdx.h"
  15614. #include <stdlib.h>
  15615. #include <stdio.h>
  15616. #include <string.h>
  15617.  
  15618. // READLEN % 64 must = 0
  15619. #define READLEN    1048576L // 2^20, 1MB
  15620.  
  15621. void DigestFile( char * );
  15622. void DigestString();
  15623.  
  15624. void main(int argc, char *argv[])
  15625. {
  15626.     printf("%s\n\n", MDxGetVersion());
  15627.  
  15628.     if( argc > 1 )
  15629.         DigestFile( argv[1] );
  15630.     else    
  15631.         DigestString();
  15632.  
  15633. }
  15634.  
  15635. /*
  15636.     I use the 'chunk' method for processing files not because of
  15637.     limitations of my dll, but think what would happen if you
  15638.     tried to load an entire cd image into memory.
  15639. */
  15640. void DigestFile( char *szFName )
  15641. {
  15642.     FILE *file;
  15643.     void *lpData;
  15644.     long flen, mlen;
  15645.     MDxSum mdDataSum;
  15646.     MDxSum md4DataSum;
  15647.  
  15648.     // the 64 is for padding purposes
  15649.     lpData = malloc( READLEN + 64 );
  15650.     
  15651.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15652.  
  15653.     file = fopen( szFName, "rb" );
  15654.     if( file == NULL )
  15655.     {
  15656.         printf("ERROR: File not found.\n");
  15657.         return;
  15658.     }
  15659.     
  15660.     MDxInit( &mdDataSum );
  15661.     MDxInit( &md4DataSum );
  15662.     
  15663.     fseek( file, 0, SEEK_END );
  15664.     //Get the file length
  15665.     flen = mlen = ftell( file );
  15666.     fseek( file, 0, SEEK_SET );
  15667.     
  15668.     // When it takes a while to process a large file,
  15669.     // remember that for each chunk it has to run 
  15670.     // through the main translation loop 16384 times!
  15671.         
  15672.     printf("Processing %ld byte file: .", flen );
  15673.     
  15674.     while( flen > READLEN )
  15675.     {
  15676.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15677.         {
  15678.             printf("READ ERROR!\n");
  15679.             return;
  15680.         }
  15681.         MD5Translate( lpData, READLEN, &mdDataSum );
  15682.         MD4Translate( lpData, READLEN, &md4DataSum );
  15683.         flen -= READLEN;
  15684.         printf(".");
  15685.     }
  15686.  
  15687.     if (fread( lpData, 1, flen, file ) != flen)
  15688.     {
  15689.         printf("READ ERROR!\n");
  15690.         return;
  15691.     }
  15692.     // This is why I added the new argument to MDxPad
  15693.     // So we can pass the length of the data AND the
  15694.     // Total length of the message
  15695.     // Also it now returns the # of padding bytes added,
  15696.     // this is for files that are an exact multiple of the chunk
  15697.     // length. (Otherwise the padding isn't Translated)
  15698.     flen += MDxPad( lpData, flen, mlen );
  15699.     MD5Translate( lpData, flen, &mdDataSum );    
  15700.     MD4Translate( lpData, flen, &md4DataSum );
  15701.  
  15702.     // New step necessary because of the 'chunking' method
  15703.     MDxFinalize( &mdDataSum );
  15704.     MDxFinalize( &md4DataSum );
  15705.     
  15706.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  15707.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15708.     fclose(file);
  15709.         
  15710. }
  15711.  
  15712. void DigestString()
  15713. {
  15714.     
  15715.     //For our demo purposes, no strings bigger than 1024 :)
  15716.     unsigned char lpData[1024] = "";
  15717.     long len = 0;
  15718.     MDxSum mdDataSum;
  15719.  
  15720.     printf("Enter the string to digest: ");
  15721.     scanf("%s", &lpData );
  15722.     len = strlen(lpData);
  15723.     
  15724.     // Have to do this before the Padding...well...it's best anyway;)
  15725.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  15726.     
  15727.     // For the strings, we're gonna pad and digest the string
  15728.     // in one pass.
  15729.     MDxInit( &mdDataSum );
  15730.     MDxPad( lpData, len, len );
  15731.     
  15732.     MD5Translate( lpData, len, &mdDataSum );
  15733.         // New step necessary because of the 'chunking' method
  15734.         MDxFinalize( &mdDataSum );
  15735.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15736.     
  15737.     MDxInit( &mdDataSum );
  15738.     MD4Translate( lpData, len, &mdDataSum );    
  15739.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15740.  
  15741.     return;
  15742. }
  15743.  
  15744.  
  15745. -------------- Include
  15746.  
  15747. #ifndef __windows_h__
  15748.         typedef unsigned long DWORD;
  15749.         #define STDCALL _stdcall
  15750. #endif
  15751.  
  15752. typedef struct 
  15753. {
  15754.     DWORD dwSum[4];
  15755. }MDxSum;
  15756.  
  15757. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  15758. void STDCALL MDxInit( MDxSum * );
  15759. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  15760. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15761. const char * STDCALL MDxGetVersion();
  15762. void STDCALL MDxFinalize( MDxSum * );
  15763.  
  15764.  
  15765.  
  15766. #include "mdx.h"
  15767. #include <stdlib.h>
  15768. #include <stdio.h>
  15769. #include <string.h>
  15770.  
  15771. // READLEN % 64 must = 0
  15772. #define READLEN    1048576L // 2^20, 1MB
  15773.  
  15774. void DigestFile( char * );
  15775. void DigestString();
  15776.  
  15777. void main(int argc, char *argv[])
  15778. {
  15779.     printf("%s\n\n", MDxGetVersion());
  15780.  
  15781.     if( argc > 1 )
  15782.         DigestFile( argv[1] );
  15783.     else    
  15784.         DigestString();
  15785.  
  15786. }
  15787.  
  15788. /*
  15789.     I use the 'chunk' method for processing files not because of
  15790.     limitations of my dll, but think what would happen if you
  15791.     tried to load an entire cd image into memory.
  15792. */
  15793. void DigestFile( char *szFName )
  15794. {
  15795.     FILE *file;
  15796.     void *lpData;
  15797.     long flen, mlen;
  15798.     MDxSum mdDataSum;
  15799.     MDxSum md4DataSum;
  15800.  
  15801.     // the 64 is for padding purposes
  15802.     lpData = malloc( READLEN + 64 );
  15803.     
  15804.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15805.  
  15806.     file = fopen( szFName, "rb" );
  15807.     if( file == NULL )
  15808.     {
  15809.         printf("ERROR: File not found.\n");
  15810.         return;
  15811.     }
  15812.     
  15813.     MDxInit( &mdDataSum );
  15814.     MDxInit( &md4DataSum );
  15815.     
  15816.     fseek( file, 0, SEEK_END );
  15817.     //Get the file length
  15818.     flen = mlen = ftell( file );
  15819.     fseek( file, 0, SEEK_SET );
  15820.     
  15821.     // When it takes a while to process a large file,
  15822.     // remember that for each chunk it has to run 
  15823.     // through the main translation loop 16384 times!
  15824.         
  15825.     printf("Processing %ld byte file: .", flen );
  15826.     
  15827.     while( flen > READLEN )
  15828.     {
  15829.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15830.         {
  15831.             printf("READ ERROR!\n");
  15832.             return;
  15833.         }
  15834.         MD5Translate( lpData, READLEN, &mdDataSum );
  15835.         MD4Translate( lpData, READLEN, &md4DataSum );
  15836.         flen -= READLEN;
  15837.         printf(".");
  15838.     }
  15839.  
  15840.     if (fread( lpData, 1, flen, file ) != flen)
  15841.     {
  15842.         printf("READ ERROR!\n");
  15843.         return;
  15844.     }
  15845.     // This is why I added the new argument to MDxPad
  15846.     // So we can pass the length of the data AND the
  15847.     // Total length of the message
  15848.     // Also it now returns the # of padding bytes added,
  15849.     // this is for files that are an exact multiple of the chunk
  15850.     // length. (Otherwise the padding isn't Translated)
  15851.     flen += MDxPad( lpData, flen, mlen );
  15852.     MD5Translate( lpData, flen, &mdDataSum );    
  15853.     MD4Translate( lpData, flen, &md4DataSum );
  15854.  
  15855.     // New step necessary because of the 'chunking' method
  15856.     MDxFinalize( &mdDataSum );
  15857.     MDxFinalize( &md4DataSum );
  15858.     
  15859.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  15860.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15861.     fclose(file);
  15862.         
  15863. }
  15864.  
  15865. void DigestString()
  15866. {
  15867.     
  15868.     //For our demo purposes, no strings bigger than 1024 :)
  15869.     unsigned char lpData[1024] = "";
  15870.     long len = 0;
  15871.     MDxSum mdDataSum;
  15872.  
  15873.     printf("Enter the string to digest: ");
  15874.     scanf("%s", &lpData );
  15875.     len = strlen(lpData);
  15876.     
  15877.     // Have to do this before the Padding...well...it's best anyway;)
  15878.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  15879.     
  15880.     // For the strings, we're gonna pad and digest the string
  15881.     // in one pass.
  15882.     MDxInit( &mdDataSum );
  15883.     MDxPad( lpData, len, len );
  15884.     
  15885.     MD5Translate( lpData, len, &mdDataSum );
  15886.         // New step necessary because of the 'chunking' method
  15887.         MDxFinalize( &mdDataSum );
  15888.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15889.     
  15890.     MDxInit( &mdDataSum );
  15891.     MD4Translate( lpData, len, &mdDataSum );    
  15892.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  15893.  
  15894.     return;
  15895. }
  15896.  
  15897.  
  15898. -------------- Include
  15899.  
  15900. #ifndef __windows_h__
  15901.         typedef unsigned long DWORD;
  15902.         #define STDCALL _stdcall
  15903. #endif
  15904.  
  15905. typedef struct 
  15906. {
  15907.     DWORD dwSum[4];
  15908. }MDxSum;
  15909.  
  15910. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  15911. void STDCALL MDxInit( MDxSum * );
  15912. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  15913. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  15914. const char * STDCALL MDxGetVersion();
  15915. void STDCALL MDxFinalize( MDxSum * );
  15916.  
  15917.  
  15918.  
  15919. #include "mdx.h"
  15920. #include <stdlib.h>
  15921. #include <stdio.h>
  15922. #include <string.h>
  15923.  
  15924. // READLEN % 64 must = 0
  15925. #define READLEN    1048576L // 2^20, 1MB
  15926.  
  15927. void DigestFile( char * );
  15928. void DigestString();
  15929.  
  15930. void main(int argc, char *argv[])
  15931. {
  15932.     printf("%s\n\n", MDxGetVersion());
  15933.  
  15934.     if( argc > 1 )
  15935.         DigestFile( argv[1] );
  15936.     else    
  15937.         DigestString();
  15938.  
  15939. }
  15940.  
  15941. /*
  15942.     I use the 'chunk' method for processing files not because of
  15943.     limitations of my dll, but think what would happen if you
  15944.     tried to load an entire cd image into memory.
  15945. */
  15946. void DigestFile( char *szFName )
  15947. {
  15948.     FILE *file;
  15949.     void *lpData;
  15950.     long flen, mlen;
  15951.     MDxSum mdDataSum;
  15952.     MDxSum md4DataSum;
  15953.  
  15954.     // the 64 is for padding purposes
  15955.     lpData = malloc( READLEN + 64 );
  15956.     
  15957.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  15958.  
  15959.     file = fopen( szFName, "rb" );
  15960.     if( file == NULL )
  15961.     {
  15962.         printf("ERROR: File not found.\n");
  15963.         return;
  15964.     }
  15965.     
  15966.     MDxInit( &mdDataSum );
  15967.     MDxInit( &md4DataSum );
  15968.     
  15969.     fseek( file, 0, SEEK_END );
  15970.     //Get the file length
  15971.     flen = mlen = ftell( file );
  15972.     fseek( file, 0, SEEK_SET );
  15973.     
  15974.     // When it takes a while to process a large file,
  15975.     // remember that for each chunk it has to run 
  15976.     // through the main translation loop 16384 times!
  15977.         
  15978.     printf("Processing %ld byte file: .", flen );
  15979.     
  15980.     while( flen > READLEN )
  15981.     {
  15982.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  15983.         {
  15984.             printf("READ ERROR!\n");
  15985.             return;
  15986.         }
  15987.         MD5Translate( lpData, READLEN, &mdDataSum );
  15988.         MD4Translate( lpData, READLEN, &md4DataSum );
  15989.         flen -= READLEN;
  15990.         printf(".");
  15991.     }
  15992.  
  15993.     if (fread( lpData, 1, flen, file ) != flen)
  15994.     {
  15995.         printf("READ ERROR!\n");
  15996.         return;
  15997.     }
  15998.     // This is why I added the new argument to MDxPad
  15999.     // So we can pass the length of the data AND the
  16000.     // Total length of the message
  16001.     // Also it now returns the # of padding bytes added,
  16002.     // this is for files that are an exact multiple of the chunk
  16003.     // length. (Otherwise the padding isn't Translated)
  16004.     flen += MDxPad( lpData, flen, mlen );
  16005.     MD5Translate( lpData, flen, &mdDataSum );    
  16006.     MD4Translate( lpData, flen, &md4DataSum );
  16007.  
  16008.     // New step necessary because of the 'chunking' method
  16009.     MDxFinalize( &mdDataSum );
  16010.     MDxFinalize( &md4DataSum );
  16011.     
  16012.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16013.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16014.     fclose(file);
  16015.         
  16016. }
  16017.  
  16018. void DigestString()
  16019. {
  16020.     
  16021.     //For our demo purposes, no strings bigger than 1024 :)
  16022.     unsigned char lpData[1024] = "";
  16023.     long len = 0;
  16024.     MDxSum mdDataSum;
  16025.  
  16026.     printf("Enter the string to digest: ");
  16027.     scanf("%s", &lpData );
  16028.     len = strlen(lpData);
  16029.     
  16030.     // Have to do this before the Padding...well...it's best anyway;)
  16031.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16032.     
  16033.     // For the strings, we're gonna pad and digest the string
  16034.     // in one pass.
  16035.     MDxInit( &mdDataSum );
  16036.     MDxPad( lpData, len, len );
  16037.     
  16038.     MD5Translate( lpData, len, &mdDataSum );
  16039.         // New step necessary because of the 'chunking' method
  16040.         MDxFinalize( &mdDataSum );
  16041.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16042.     
  16043.     MDxInit( &mdDataSum );
  16044.     MD4Translate( lpData, len, &mdDataSum );    
  16045.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16046.  
  16047.     return;
  16048. }
  16049.  
  16050.  
  16051. -------------- Include
  16052.  
  16053. #ifndef __windows_h__
  16054.         typedef unsigned long DWORD;
  16055.         #define STDCALL _stdcall
  16056. #endif
  16057.  
  16058. typedef struct 
  16059. {
  16060.     DWORD dwSum[4];
  16061. }MDxSum;
  16062.  
  16063. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16064. void STDCALL MDxInit( MDxSum * );
  16065. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16066. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16067. const char * STDCALL MDxGetVersion();
  16068. void STDCALL MDxFinalize( MDxSum * );
  16069.  
  16070.  
  16071.  
  16072. #include "mdx.h"
  16073. #include <stdlib.h>
  16074. #include <stdio.h>
  16075. #include <string.h>
  16076.  
  16077. // READLEN % 64 must = 0
  16078. #define READLEN    1048576L // 2^20, 1MB
  16079.  
  16080. void DigestFile( char * );
  16081. void DigestString();
  16082.  
  16083. void main(int argc, char *argv[])
  16084. {
  16085.     printf("%s\n\n", MDxGetVersion());
  16086.  
  16087.     if( argc > 1 )
  16088.         DigestFile( argv[1] );
  16089.     else    
  16090.         DigestString();
  16091.  
  16092. }
  16093.  
  16094. /*
  16095.     I use the 'chunk' method for processing files not because of
  16096.     limitations of my dll, but think what would happen if you
  16097.     tried to load an entire cd image into memory.
  16098. */
  16099. void DigestFile( char *szFName )
  16100. {
  16101.     FILE *file;
  16102.     void *lpData;
  16103.     long flen, mlen;
  16104.     MDxSum mdDataSum;
  16105.     MDxSum md4DataSum;
  16106.  
  16107.     // the 64 is for padding purposes
  16108.     lpData = malloc( READLEN + 64 );
  16109.     
  16110.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  16111.  
  16112.     file = fopen( szFName, "rb" );
  16113.     if( file == NULL )
  16114.     {
  16115.         printf("ERROR: File not found.\n");
  16116.         return;
  16117.     }
  16118.     
  16119.     MDxInit( &mdDataSum );
  16120.     MDxInit( &md4DataSum );
  16121.     
  16122.     fseek( file, 0, SEEK_END );
  16123.     //Get the file length
  16124.     flen = mlen = ftell( file );
  16125.     fseek( file, 0, SEEK_SET );
  16126.     
  16127.     // When it takes a while to process a large file,
  16128.     // remember that for each chunk it has to run 
  16129.     // through the main translation loop 16384 times!
  16130.         
  16131.     printf("Processing %ld byte file: .", flen );
  16132.     
  16133.     while( flen > READLEN )
  16134.     {
  16135.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  16136.         {
  16137.             printf("READ ERROR!\n");
  16138.             return;
  16139.         }
  16140.         MD5Translate( lpData, READLEN, &mdDataSum );
  16141.         MD4Translate( lpData, READLEN, &md4DataSum );
  16142.         flen -= READLEN;
  16143.         printf(".");
  16144.     }
  16145.  
  16146.     if (fread( lpData, 1, flen, file ) != flen)
  16147.     {
  16148.         printf("READ ERROR!\n");
  16149.         return;
  16150.     }
  16151.     // This is why I added the new argument to MDxPad
  16152.     // So we can pass the length of the data AND the
  16153.     // Total length of the message
  16154.     // Also it now returns the # of padding bytes added,
  16155.     // this is for files that are an exact multiple of the chunk
  16156.     // length. (Otherwise the padding isn't Translated)
  16157.     flen += MDxPad( lpData, flen, mlen );
  16158.     MD5Translate( lpData, flen, &mdDataSum );    
  16159.     MD4Translate( lpData, flen, &md4DataSum );
  16160.  
  16161.     // New step necessary because of the 'chunking' method
  16162.     MDxFinalize( &mdDataSum );
  16163.     MDxFinalize( &md4DataSum );
  16164.     
  16165.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16166.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16167.     fclose(file);
  16168.         
  16169. }
  16170.  
  16171. void DigestString()
  16172. {
  16173.     
  16174.     //For our demo purposes, no strings bigger than 1024 :)
  16175.     unsigned char lpData[1024] = "";
  16176.     long len = 0;
  16177.     MDxSum mdDataSum;
  16178.  
  16179.     printf("Enter the string to digest: ");
  16180.     scanf("%s", &lpData );
  16181.     len = strlen(lpData);
  16182.     
  16183.     // Have to do this before the Padding...well...it's best anyway;)
  16184.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16185.     
  16186.     // For the strings, we're gonna pad and digest the string
  16187.     // in one pass.
  16188.     MDxInit( &mdDataSum );
  16189.     MDxPad( lpData, len, len );
  16190.     
  16191.     MD5Translate( lpData, len, &mdDataSum );
  16192.         // New step necessary because of the 'chunking' method
  16193.         MDxFinalize( &mdDataSum );
  16194.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16195.     
  16196.     MDxInit( &mdDataSum );
  16197.     MD4Translate( lpData, len, &mdDataSum );    
  16198.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16199.  
  16200.     return;
  16201. }
  16202.  
  16203.  
  16204. -------------- Include
  16205.  
  16206. #ifndef __windows_h__
  16207.         typedef unsigned long DWORD;
  16208.         #define STDCALL _stdcall
  16209. #endif
  16210.  
  16211. typedef struct 
  16212. {
  16213.     DWORD dwSum[4];
  16214. }MDxSum;
  16215.  
  16216. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16217. void STDCALL MDxInit( MDxSum * );
  16218. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16219. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16220. const char * STDCALL MDxGetVersion();
  16221. void STDCALL MDxFinalize( MDxSum * );
  16222.  
  16223.  
  16224.  
  16225. #include "mdx.h"
  16226. #include <stdlib.h>
  16227. #include <stdio.h>
  16228. #include <string.h>
  16229.  
  16230. // READLEN % 64 must = 0
  16231. #define READLEN    1048576L // 2^20, 1MB
  16232.  
  16233. void DigestFile( char * );
  16234. void DigestString();
  16235.  
  16236. void main(int argc, char *argv[])
  16237. {
  16238.     printf("%s\n\n", MDxGetVersion());
  16239.  
  16240.     if( argc > 1 )
  16241.         DigestFile( argv[1] );
  16242.     else    
  16243.         DigestString();
  16244.  
  16245. }
  16246.  
  16247. /*
  16248.     I use the 'chunk' method for processing files not because of
  16249.     limitations of my dll, but think what would happen if you
  16250.     tried to load an entire cd image into memory.
  16251. */
  16252. void DigestFile( char *szFName )
  16253. {
  16254.     FILE *file;
  16255.     void *lpData;
  16256.     long flen, mlen;
  16257.     MDxSum mdDataSum;
  16258.     MDxSum md4DataSum;
  16259.  
  16260.     // the 64 is for padding purposes
  16261.     lpData = malloc( READLEN + 64 );
  16262.     
  16263.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  16264.  
  16265.     file = fopen( szFName, "rb" );
  16266.     if( file == NULL )
  16267.     {
  16268.         printf("ERROR: File not found.\n");
  16269.         return;
  16270.     }
  16271.     
  16272.     MDxInit( &mdDataSum );
  16273.     MDxInit( &md4DataSum );
  16274.     
  16275.     fseek( file, 0, SEEK_END );
  16276.     //Get the file length
  16277.     flen = mlen = ftell( file );
  16278.     fseek( file, 0, SEEK_SET );
  16279.     
  16280.     // When it takes a while to process a large file,
  16281.     // remember that for each chunk it has to run 
  16282.     // through the main translation loop 16384 times!
  16283.         
  16284.     printf("Processing %ld byte file: .", flen );
  16285.     
  16286.     while( flen > READLEN )
  16287.     {
  16288.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  16289.         {
  16290.             printf("READ ERROR!\n");
  16291.             return;
  16292.         }
  16293.         MD5Translate( lpData, READLEN, &mdDataSum );
  16294.         MD4Translate( lpData, READLEN, &md4DataSum );
  16295.         flen -= READLEN;
  16296.         printf(".");
  16297.     }
  16298.  
  16299.     if (fread( lpData, 1, flen, file ) != flen)
  16300.     {
  16301.         printf("READ ERROR!\n");
  16302.         return;
  16303.     }
  16304.     // This is why I added the new argument to MDxPad
  16305.     // So we can pass the length of the data AND the
  16306.     // Total length of the message
  16307.     // Also it now returns the # of padding bytes added,
  16308.     // this is for files that are an exact multiple of the chunk
  16309.     // length. (Otherwise the padding isn't Translated)
  16310.     flen += MDxPad( lpData, flen, mlen );
  16311.     MD5Translate( lpData, flen, &mdDataSum );    
  16312.     MD4Translate( lpData, flen, &md4DataSum );
  16313.  
  16314.     // New step necessary because of the 'chunking' method
  16315.     MDxFinalize( &mdDataSum );
  16316.     MDxFinalize( &md4DataSum );
  16317.     
  16318.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16319.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16320.     fclose(file);
  16321.         
  16322. }
  16323.  
  16324. void DigestString()
  16325. {
  16326.     
  16327.     //For our demo purposes, no strings bigger than 1024 :)
  16328.     unsigned char lpData[1024] = "";
  16329.     long len = 0;
  16330.     MDxSum mdDataSum;
  16331.  
  16332.     printf("Enter the string to digest: ");
  16333.     scanf("%s", &lpData );
  16334.     len = strlen(lpData);
  16335.     
  16336.     // Have to do this before the Padding...well...it's best anyway;)
  16337.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16338.     
  16339.     // For the strings, we're gonna pad and digest the string
  16340.     // in one pass.
  16341.     MDxInit( &mdDataSum );
  16342.     MDxPad( lpData, len, len );
  16343.     
  16344.     MD5Translate( lpData, len, &mdDataSum );
  16345.         // New step necessary because of the 'chunking' method
  16346.         MDxFinalize( &mdDataSum );
  16347.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16348.     
  16349.     MDxInit( &mdDataSum );
  16350.     MD4Translate( lpData, len, &mdDataSum );    
  16351.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16352.  
  16353.     return;
  16354. }
  16355.  
  16356.  
  16357. -------------- Include
  16358.  
  16359. #ifndef __windows_h__
  16360.         typedef unsigned long DWORD;
  16361.         #define STDCALL _stdcall
  16362. #endif
  16363.  
  16364. typedef struct 
  16365. {
  16366.     DWORD dwSum[4];
  16367. }MDxSum;
  16368.  
  16369. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16370. void STDCALL MDxInit( MDxSum * );
  16371. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16372. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16373. const char * STDCALL MDxGetVersion();
  16374. void STDCALL MDxFinalize( MDxSum * );
  16375.  
  16376.  
  16377.  
  16378.  
  16379. #include "mdx.h"
  16380. #include <stdlib.h>
  16381. #include <stdio.h>
  16382. #include <string.h>
  16383.  
  16384. // READLEN % 64 must = 0
  16385. #define READLEN    1048576L // 2^20, 1MB
  16386.  
  16387. void DigestFile( char * );
  16388. void DigestString();
  16389.  
  16390. void main(int argc, char *argv[])
  16391. {
  16392.     printf("%s\n\n", MDxGetVersion());
  16393.  
  16394.     if( argc > 1 )
  16395.         DigestFile( argv[1] );
  16396.     else    
  16397.         DigestString();
  16398.  
  16399. }
  16400.  
  16401. /*
  16402.     I use the 'chunk' method for processing files not because of
  16403.     limitations of my dll, but think what would happen if you
  16404.     tried to load an entire cd image into memory.
  16405. */
  16406. void DigestFile( char *szFName )
  16407. {
  16408.     FILE *file;
  16409.     void *lpData;
  16410.     long flen, mlen;
  16411.     MDxSum mdDataSum;
  16412.     MDxSum md4DataSum;
  16413.  
  16414.     // the 64 is for padding purposes
  16415.     lpData = malloc( READLEN + 64 );
  16416.     
  16417.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  16418.  
  16419.     file = fopen( szFName, "rb" );
  16420.     if( file == NULL )
  16421.     {
  16422.         printf("ERROR: File not found.\n");
  16423.         return;
  16424.     }
  16425.     
  16426.     MDxInit( &mdDataSum );
  16427.     MDxInit( &md4DataSum );
  16428.     
  16429.     fseek( file, 0, SEEK_END );
  16430.     //Get the file length
  16431.     flen = mlen = ftell( file );
  16432.     fseek( file, 0, SEEK_SET );
  16433.     
  16434.     // When it takes a while to process a large file,
  16435.     // remember that for each chunk it has to run 
  16436.     // through the main translation loop 16384 times!
  16437.         
  16438.     printf("Processing %ld byte file: .", flen );
  16439.     
  16440.     while( flen > READLEN )
  16441.     {
  16442.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  16443.         {
  16444.             printf("READ ERROR!\n");
  16445.             return;
  16446.         }
  16447.         MD5Translate( lpData, READLEN, &mdDataSum );
  16448.         MD4Translate( lpData, READLEN, &md4DataSum );
  16449.         flen -= READLEN;
  16450.         printf(".");
  16451.     }
  16452.  
  16453.     if (fread( lpData, 1, flen, file ) != flen)
  16454.     {
  16455.         printf("READ ERROR!\n");
  16456.         return;
  16457.     }
  16458.     // This is why I added the new argument to MDxPad
  16459.     // So we can pass the length of the data AND the
  16460.     // Total length of the message
  16461.     // Also it now returns the # of padding bytes added,
  16462.     // this is for files that are an exact multiple of the chunk
  16463.     // length. (Otherwise the padding isn't Translated)
  16464.     flen += MDxPad( lpData, flen, mlen );
  16465.     MD5Translate( lpData, flen, &mdDataSum );    
  16466.     MD4Translate( lpData, flen, &md4DataSum );
  16467.  
  16468.     // New step necessary because of the 'chunking' method
  16469.     MDxFinalize( &mdDataSum );
  16470.     MDxFinalize( &md4DataSum );
  16471.     
  16472.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16473.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16474.     fclose(file);
  16475.         
  16476. }
  16477.  
  16478. void DigestString()
  16479. {
  16480.     
  16481.     //For our demo purposes, no strings bigger than 1024 :)
  16482.     unsigned char lpData[1024] = "";
  16483.     long len = 0;
  16484.     MDxSum mdDataSum;
  16485.  
  16486.     printf("Enter the string to digest: ");
  16487.     scanf("%s", &lpData );
  16488.     len = strlen(lpData);
  16489.     
  16490.     // Have to do this before the Padding...well...it's best anyway;)
  16491.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16492.     
  16493.     // For the strings, we're gonna pad and digest the string
  16494.     // in one pass.
  16495.     MDxInit( &mdDataSum );
  16496.     MDxPad( lpData, len, len );
  16497.     
  16498.     MD5Translate( lpData, len, &mdDataSum );
  16499.         // New step necessary because of the 'chunking' method
  16500.         MDxFinalize( &mdDataSum );
  16501.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16502.     
  16503.     MDxInit( &mdDataSum );
  16504.     MD4Translate( lpData, len, &mdDataSum );    
  16505.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16506.  
  16507.     return;
  16508. }
  16509.  
  16510.  
  16511. -------------- Include
  16512.  
  16513. #ifndef __windows_h__
  16514.         typedef unsigned long DWORD;
  16515.         #define STDCALL _stdcall
  16516. #endif
  16517.  
  16518. typedef struct 
  16519. {
  16520.     DWORD dwSum[4];
  16521. }MDxSum;
  16522.  
  16523. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16524. void STDCALL MDxInit( MDxSum * );
  16525. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16526. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16527. const char * STDCALL MDxGetVersion();
  16528. void STDCALL MDxFinalize( MDxSum * );
  16529.  
  16530.  
  16531.  
  16532.  
  16533. #include "mdx.h"
  16534. #include <stdlib.h>
  16535. #include <stdio.h>
  16536. #include <string.h>
  16537.  
  16538. // READLEN % 64 must = 0
  16539. #define READLEN    1048576L // 2^20, 1MB
  16540.  
  16541. void DigestFile( char * );
  16542. void DigestString();
  16543.  
  16544. void main(int argc, char *argv[])
  16545. {
  16546.     printf("%s\n\n", MDxGetVersion());
  16547.  
  16548.     if( argc > 1 )
  16549.         DigestFile( argv[1] );
  16550.     else    
  16551.         DigestString();
  16552.  
  16553. }
  16554.  
  16555. /*
  16556.     I use the 'chunk' method for processing files not because of
  16557.     limitations of my dll, but think what would happen if you
  16558.     tried to load an entire cd image into memory.
  16559. */
  16560. void DigestFile( char *szFName )
  16561. {
  16562.     FILE *file;
  16563.     void *lpData;
  16564.     long flen, mlen;
  16565.     MDxSum mdDataSum;
  16566.     MDxSum md4DataSum;
  16567.  
  16568.     // the 64 is for padding purposes
  16569.     lpData = malloc( READLEN + 64 );
  16570.     
  16571.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  16572.  
  16573.     file = fopen( szFName, "rb" );
  16574.     if( file == NULL )
  16575.     {
  16576.         printf("ERROR: File not found.\n");
  16577.         return;
  16578.     }
  16579.     
  16580.     MDxInit( &mdDataSum );
  16581.     MDxInit( &md4DataSum );
  16582.     
  16583.     fseek( file, 0, SEEK_END );
  16584.     //Get the file length
  16585.     flen = mlen = ftell( file );
  16586.     fseek( file, 0, SEEK_SET );
  16587.     
  16588.     // When it takes a while to process a large file,
  16589.     // remember that for each chunk it has to run 
  16590.     // through the main translation loop 16384 times!
  16591.         
  16592.     printf("Processing %ld byte file: .", flen );
  16593.     
  16594.     while( flen > READLEN )
  16595.     {
  16596.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  16597.         {
  16598.             printf("READ ERROR!\n");
  16599.             return;
  16600.         }
  16601.         MD5Translate( lpData, READLEN, &mdDataSum );
  16602.         MD4Translate( lpData, READLEN, &md4DataSum );
  16603.         flen -= READLEN;
  16604.         printf(".");
  16605.     }
  16606.  
  16607.     if (fread( lpData, 1, flen, file ) != flen)
  16608.     {
  16609.         printf("READ ERROR!\n");
  16610.         return;
  16611.     }
  16612.     // This is why I added the new argument to MDxPad
  16613.     // So we can pass the length of the data AND the
  16614.     // Total length of the message
  16615.     // Also it now returns the # of padding bytes added,
  16616.     // this is for files that are an exact multiple of the chunk
  16617.     // length. (Otherwise the padding isn't Translated)
  16618.     flen += MDxPad( lpData, flen, mlen );
  16619.     MD5Translate( lpData, flen, &mdDataSum );    
  16620.     MD4Translate( lpData, flen, &md4DataSum );
  16621.  
  16622.     // New step necessary because of the 'chunking' method
  16623.     MDxFinalize( &mdDataSum );
  16624.     MDxFinalize( &md4DataSum );
  16625.     
  16626.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16627.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16628.     fclose(file);
  16629.         
  16630. }
  16631.  
  16632. void DigestString()
  16633. {
  16634.     
  16635.     //For our demo purposes, no strings bigger than 1024 :)
  16636.     unsigned char lpData[1024] = "";
  16637.     long len = 0;
  16638.     MDxSum mdDataSum;
  16639.  
  16640.     printf("Enter the string to digest: ");
  16641.     scanf("%s", &lpData );
  16642.     len = strlen(lpData);
  16643.     
  16644.     // Have to do this before the Padding...well...it's best anyway;)
  16645.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16646.     
  16647.     // For the strings, we're gonna pad and digest the string
  16648.     // in one pass.
  16649.     MDxInit( &mdDataSum );
  16650.     MDxPad( lpData, len, len );
  16651.     
  16652.     MD5Translate( lpData, len, &mdDataSum );
  16653.         // New step necessary because of the 'chunking' method
  16654.         MDxFinalize( &mdDataSum );
  16655.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16656.     
  16657.     MDxInit( &mdDataSum );
  16658.     MD4Translate( lpData, len, &mdDataSum );    
  16659.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16660.  
  16661.     return;
  16662. }
  16663.  
  16664.  
  16665. -------------- Include
  16666.  
  16667. #ifndef __windows_h__
  16668.         typedef unsigned long DWORD;
  16669.         #define STDCALL _stdcall
  16670. #endif
  16671.  
  16672. typedef struct 
  16673. {
  16674.     DWORD dwSum[4];
  16675. }MDxSum;
  16676.  
  16677. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16678. void STDCALL MDxInit( MDxSum * );
  16679. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16680. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16681. const char * STDCALL MDxGetVersion();
  16682. void STDCALL MDxFinalize( MDxSum * );
  16683.  
  16684.  
  16685.  
  16686.  
  16687. #include "mdx.h"
  16688. #include <stdlib.h>
  16689. #include <stdio.h>
  16690. #include <string.h>
  16691.  
  16692. // READLEN % 64 must = 0
  16693. #define READLEN    1048576L // 2^20, 1MB
  16694.  
  16695. void DigestFile( char * );
  16696. void DigestString();
  16697.  
  16698. void main(int argc, char *argv[])
  16699. {
  16700.     printf("%s\n\n", MDxGetVersion());
  16701.  
  16702.     if( argc > 1 )
  16703.         DigestFile( argv[1] );
  16704.     else    
  16705.         DigestString();
  16706.  
  16707. }
  16708.  
  16709. /*
  16710.     I use the 'chunk' method for processing files not because of
  16711.     limitations of my dll, but think what would happen if you
  16712.     tried to load an entire cd image into memory.
  16713. */
  16714. void DigestFile( char *szFName )
  16715. {
  16716.     FILE *file;
  16717.     void *lpData;
  16718.     long flen, mlen;
  16719.     MDxSum mdDataSum;
  16720.     MDxSum md4DataSum;
  16721.  
  16722.     // the 64 is for padding purposes
  16723.     lpData = malloc( READLEN + 64 );
  16724.     
  16725.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  16726.  
  16727.     file = fopen( szFName, "rb" );
  16728.     if( file == NULL )
  16729.     {
  16730.         printf("ERROR: File not found.\n");
  16731.         return;
  16732.     }
  16733.     
  16734.     MDxInit( &mdDataSum );
  16735.     MDxInit( &md4DataSum );
  16736.     
  16737.     fseek( file, 0, SEEK_END );
  16738.     //Get the file length
  16739.     flen = mlen = ftell( file );
  16740.     fseek( file, 0, SEEK_SET );
  16741.     
  16742.     // When it takes a while to process a large file,
  16743.     // remember that for each chunk it has to run 
  16744.     // through the main translation loop 16384 times!
  16745.         
  16746.     printf("Processing %ld byte file: .", flen );
  16747.     
  16748.     while( flen > READLEN )
  16749.     {
  16750.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  16751.         {
  16752.             printf("READ ERROR!\n");
  16753.             return;
  16754.         }
  16755.         MD5Translate( lpData, READLEN, &mdDataSum );
  16756.         MD4Translate( lpData, READLEN, &md4DataSum );
  16757.         flen -= READLEN;
  16758.         printf(".");
  16759.     }
  16760.  
  16761.     if (fread( lpData, 1, flen, file ) != flen)
  16762.     {
  16763.         printf("READ ERROR!\n");
  16764.         return;
  16765.     }
  16766.     // This is why I added the new argument to MDxPad
  16767.     // So we can pass the length of the data AND the
  16768.     // Total length of the message
  16769.     // Also it now returns the # of padding bytes added,
  16770.     // this is for files that are an exact multiple of the chunk
  16771.     // length. (Otherwise the padding isn't Translated)
  16772.     flen += MDxPad( lpData, flen, mlen );
  16773.     MD5Translate( lpData, flen, &mdDataSum );    
  16774.     MD4Translate( lpData, flen, &md4DataSum );
  16775.  
  16776.     // New step necessary because of the 'chunking' method
  16777.     MDxFinalize( &mdDataSum );
  16778.     MDxFinalize( &md4DataSum );
  16779.     
  16780.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16781.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16782.     fclose(file);
  16783.         
  16784. }
  16785.  
  16786. void DigestString()
  16787. {
  16788.     
  16789.     //For our demo purposes, no strings bigger than 1024 :)
  16790.     unsigned char lpData[1024] = "";
  16791.     long len = 0;
  16792.     MDxSum mdDataSum;
  16793.  
  16794.     printf("Enter the string to digest: ");
  16795.     scanf("%s", &lpData );
  16796.     len = strlen(lpData);
  16797.     
  16798.     // Have to do this before the Padding...well...it's best anyway;)
  16799.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16800.     
  16801.     // For the strings, we're gonna pad and digest the string
  16802.     // in one pass.
  16803.     MDxInit( &mdDataSum );
  16804.     MDxPad( lpData, len, len );
  16805.     
  16806.     MD5Translate( lpData, len, &mdDataSum );
  16807.         // New step necessary because of the 'chunking' method
  16808.         MDxFinalize( &mdDataSum );
  16809.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16810.     
  16811.     MDxInit( &mdDataSum );
  16812.     MD4Translate( lpData, len, &mdDataSum );    
  16813.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16814.  
  16815.     return;
  16816. }
  16817.  
  16818.  
  16819. -------------- Include
  16820.  
  16821. #ifndef __windows_h__
  16822.         typedef unsigned long DWORD;
  16823.         #define STDCALL _stdcall
  16824. #endif
  16825.  
  16826. typedef struct 
  16827. {
  16828.     DWORD dwSum[4];
  16829. }MDxSum;
  16830.  
  16831. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16832. void STDCALL MDxInit( MDxSum * );
  16833. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16834. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16835. const char * STDCALL MDxGetVersion();
  16836. void STDCALL MDxFinalize( MDxSum * );
  16837.  
  16838.  
  16839.  
  16840. #include "mdx.h"
  16841. #include <stdlib.h>
  16842. #include <stdio.h>
  16843. #include <string.h>
  16844.  
  16845. // READLEN % 64 must = 0
  16846. #define READLEN    1048576L // 2^20, 1MB
  16847.  
  16848. void DigestFile( char * );
  16849. void DigestString();
  16850.  
  16851. void main(int argc, char *argv[])
  16852. {
  16853.     printf("%s\n\n", MDxGetVersion());
  16854.  
  16855.     if( argc > 1 )
  16856.         DigestFile( argv[1] );
  16857.     else    
  16858.         DigestString();
  16859.  
  16860. }
  16861.  
  16862. /*
  16863.     I use the 'chunk' method for processing files not because of
  16864.     limitations of my dll, but think what would happen if you
  16865.     tried to load an entire cd image into memory.
  16866. */
  16867. void DigestFile( char *szFName )
  16868. {
  16869.     FILE *file;
  16870.     void *lpData;
  16871.     long flen, mlen;
  16872.     MDxSum mdDataSum;
  16873.     MDxSum md4DataSum;
  16874.  
  16875.     // the 64 is for padding purposes
  16876.     lpData = malloc( READLEN + 64 );
  16877.     
  16878.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  16879.  
  16880.     file = fopen( szFName, "rb" );
  16881.     if( file == NULL )
  16882.     {
  16883.         printf("ERROR: File not found.\n");
  16884.         return;
  16885.     }
  16886.     
  16887.     MDxInit( &mdDataSum );
  16888.     MDxInit( &md4DataSum );
  16889.     
  16890.     fseek( file, 0, SEEK_END );
  16891.     //Get the file length
  16892.     flen = mlen = ftell( file );
  16893.     fseek( file, 0, SEEK_SET );
  16894.     
  16895.     // When it takes a while to process a large file,
  16896.     // remember that for each chunk it has to run 
  16897.     // through the main translation loop 16384 times!
  16898.         
  16899.     printf("Processing %ld byte file: .", flen );
  16900.     
  16901.     while( flen > READLEN )
  16902.     {
  16903.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  16904.         {
  16905.             printf("READ ERROR!\n");
  16906.             return;
  16907.         }
  16908.         MD5Translate( lpData, READLEN, &mdDataSum );
  16909.         MD4Translate( lpData, READLEN, &md4DataSum );
  16910.         flen -= READLEN;
  16911.         printf(".");
  16912.     }
  16913.  
  16914.     if (fread( lpData, 1, flen, file ) != flen)
  16915.     {
  16916.         printf("READ ERROR!\n");
  16917.         return;
  16918.     }
  16919.     // This is why I added the new argument to MDxPad
  16920.     // So we can pass the length of the data AND the
  16921.     // Total length of the message
  16922.     // Also it now returns the # of padding bytes added,
  16923.     // this is for files that are an exact multiple of the chunk
  16924.     // length. (Otherwise the padding isn't Translated)
  16925.     flen += MDxPad( lpData, flen, mlen );
  16926.     MD5Translate( lpData, flen, &mdDataSum );    
  16927.     MD4Translate( lpData, flen, &md4DataSum );
  16928.  
  16929.     // New step necessary because of the 'chunking' method
  16930.     MDxFinalize( &mdDataSum );
  16931.     MDxFinalize( &md4DataSum );
  16932.     
  16933.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  16934.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16935.     fclose(file);
  16936.         
  16937. }
  16938.  
  16939. void DigestString()
  16940. {
  16941.     
  16942.     //For our demo purposes, no strings bigger than 1024 :)
  16943.     unsigned char lpData[1024] = "";
  16944.     long len = 0;
  16945.     MDxSum mdDataSum;
  16946.  
  16947.     printf("Enter the string to digest: ");
  16948.     scanf("%s", &lpData );
  16949.     len = strlen(lpData);
  16950.     
  16951.     // Have to do this before the Padding...well...it's best anyway;)
  16952.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  16953.     
  16954.     // For the strings, we're gonna pad and digest the string
  16955.     // in one pass.
  16956.     MDxInit( &mdDataSum );
  16957.     MDxPad( lpData, len, len );
  16958.     
  16959.     MD5Translate( lpData, len, &mdDataSum );
  16960.         // New step necessary because of the 'chunking' method
  16961.         MDxFinalize( &mdDataSum );
  16962.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16963.     
  16964.     MDxInit( &mdDataSum );
  16965.     MD4Translate( lpData, len, &mdDataSum );    
  16966.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  16967.  
  16968.     return;
  16969. }
  16970.  
  16971.  
  16972. -------------- Include
  16973.  
  16974. #ifndef __windows_h__
  16975.         typedef unsigned long DWORD;
  16976.         #define STDCALL _stdcall
  16977. #endif
  16978.  
  16979. typedef struct 
  16980. {
  16981.     DWORD dwSum[4];
  16982. }MDxSum;
  16983.  
  16984. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  16985. void STDCALL MDxInit( MDxSum * );
  16986. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  16987. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  16988. const char * STDCALL MDxGetVersion();
  16989. void STDCALL MDxFinalize( MDxSum * );
  16990.  
  16991.  
  16992.  
  16993. #include "mdx.h"
  16994. #include <stdlib.h>
  16995. #include <stdio.h>
  16996. #include <string.h>
  16997.  
  16998. // READLEN % 64 must = 0
  16999. #define READLEN    1048576L // 2^20, 1MB
  17000.  
  17001. void DigestFile( char * );
  17002. void DigestString();
  17003.  
  17004. void main(int argc, char *argv[])
  17005. {
  17006.     printf("%s\n\n", MDxGetVersion());
  17007.  
  17008.     if( argc > 1 )
  17009.         DigestFile( argv[1] );
  17010.     else    
  17011.         DigestString();
  17012.  
  17013. }
  17014.  
  17015. /*
  17016.     I use the 'chunk' method for processing files not because of
  17017.     limitations of my dll, but think what would happen if you
  17018.     tried to load an entire cd image into memory.
  17019. */
  17020. void DigestFile( char *szFName )
  17021. {
  17022.     FILE *file;
  17023.     void *lpData;
  17024.     long flen, mlen;
  17025.     MDxSum mdDataSum;
  17026.     MDxSum md4DataSum;
  17027.  
  17028.     // the 64 is for padding purposes
  17029.     lpData = malloc( READLEN + 64 );
  17030.     
  17031.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17032.  
  17033.     file = fopen( szFName, "rb" );
  17034.     if( file == NULL )
  17035.     {
  17036.         printf("ERROR: File not found.\n");
  17037.         return;
  17038.     }
  17039.     
  17040.     MDxInit( &mdDataSum );
  17041.     MDxInit( &md4DataSum );
  17042.     
  17043.     fseek( file, 0, SEEK_END );
  17044.     //Get the file length
  17045.     flen = mlen = ftell( file );
  17046.     fseek( file, 0, SEEK_SET );
  17047.     
  17048.     // When it takes a while to process a large file,
  17049.     // remember that for each chunk it has to run 
  17050.     // through the main translation loop 16384 times!
  17051.         
  17052.     printf("Processing %ld byte file: .", flen );
  17053.     
  17054.     while( flen > READLEN )
  17055.     {
  17056.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17057.         {
  17058.             printf("READ ERROR!\n");
  17059.             return;
  17060.         }
  17061.         MD5Translate( lpData, READLEN, &mdDataSum );
  17062.         MD4Translate( lpData, READLEN, &md4DataSum );
  17063.         flen -= READLEN;
  17064.         printf(".");
  17065.     }
  17066.  
  17067.     if (fread( lpData, 1, flen, file ) != flen)
  17068.     {
  17069.         printf("READ ERROR!\n");
  17070.         return;
  17071.     }
  17072.     // This is why I added the new argument to MDxPad
  17073.     // So we can pass the length of the data AND the
  17074.     // Total length of the message
  17075.     // Also it now returns the # of padding bytes added,
  17076.     // this is for files that are an exact multiple of the chunk
  17077.     // length. (Otherwise the padding isn't Translated)
  17078.     flen += MDxPad( lpData, flen, mlen );
  17079.     MD5Translate( lpData, flen, &mdDataSum );    
  17080.     MD4Translate( lpData, flen, &md4DataSum );
  17081.  
  17082.     // New step necessary because of the 'chunking' method
  17083.     MDxFinalize( &mdDataSum );
  17084.     MDxFinalize( &md4DataSum );
  17085.     
  17086.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  17087.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17088.     fclose(file);
  17089.         
  17090. }
  17091.  
  17092. void DigestString()
  17093. {
  17094.     
  17095.     //For our demo purposes, no strings bigger than 1024 :)
  17096.     unsigned char lpData[1024] = "";
  17097.     long len = 0;
  17098.     MDxSum mdDataSum;
  17099.  
  17100.     printf("Enter the string to digest: ");
  17101.     scanf("%s", &lpData );
  17102.     len = strlen(lpData);
  17103.     
  17104.     // Have to do this before the Padding...well...it's best anyway;)
  17105.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  17106.     
  17107.     // For the strings, we're gonna pad and digest the string
  17108.     // in one pass.
  17109.     MDxInit( &mdDataSum );
  17110.     MDxPad( lpData, len, len );
  17111.     
  17112.     MD5Translate( lpData, len, &mdDataSum );
  17113.         // New step necessary because of the 'chunking' method
  17114.         MDxFinalize( &mdDataSum );
  17115.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17116.     
  17117.     MDxInit( &mdDataSum );
  17118.     MD4Translate( lpData, len, &mdDataSum );    
  17119.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17120.  
  17121.     return;
  17122. }
  17123.  
  17124.  
  17125. -------------- Include
  17126.  
  17127. #ifndef __windows_h__
  17128.         typedef unsigned long DWORD;
  17129.         #define STDCALL _stdcall
  17130. #endif
  17131.  
  17132. typedef struct 
  17133. {
  17134.     DWORD dwSum[4];
  17135. }MDxSum;
  17136.  
  17137. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  17138. void STDCALL MDxInit( MDxSum * );
  17139. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  17140. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  17141. const char * STDCALL MDxGetVersion();
  17142. void STDCALL MDxFinalize( MDxSum * );
  17143.  
  17144.  
  17145.  
  17146.  
  17147. #include "mdx.h"
  17148. #include <stdlib.h>
  17149. #include <stdio.h>
  17150. #include <string.h>
  17151.  
  17152. // READLEN % 64 must = 0
  17153. #define READLEN    1048576L // 2^20, 1MB
  17154.  
  17155. void DigestFile( char * );
  17156. void DigestString();
  17157.  
  17158. void main(int argc, char *argv[])
  17159. {
  17160.     printf("%s\n\n", MDxGetVersion());
  17161.  
  17162.     if( argc > 1 )
  17163.         DigestFile( argv[1] );
  17164.     else    
  17165.         DigestString();
  17166.  
  17167. }
  17168.  
  17169. /*
  17170.     I use the 'chunk' method for processing files not because of
  17171.     limitations of my dll, but think what would happen if you
  17172.     tried to load an entire cd image into memory.
  17173. */
  17174. void DigestFile( char *szFName )
  17175. {
  17176.     FILE *file;
  17177.     void *lpData;
  17178.     long flen, mlen;
  17179.     MDxSum mdDataSum;
  17180.     MDxSum md4DataSum;
  17181.  
  17182.     // the 64 is for padding purposes
  17183.     lpData = malloc( READLEN + 64 );
  17184.     
  17185.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17186.  
  17187.     file = fopen( szFName, "rb" );
  17188.     if( file == NULL )
  17189.     {
  17190.         printf("ERROR: File not found.\n");
  17191.         return;
  17192.     }
  17193.     
  17194.     MDxInit( &mdDataSum );
  17195.     MDxInit( &md4DataSum );
  17196.     
  17197.     fseek( file, 0, SEEK_END );
  17198.     //Get the file length
  17199.     flen = mlen = ftell( file );
  17200.     fseek( file, 0, SEEK_SET );
  17201.     
  17202.     // When it takes a while to process a large file,
  17203.     // remember that for each chunk it has to run 
  17204.     // through the main translation loop 16384 times!
  17205.         
  17206.     printf("Processing %ld byte file: .", flen );
  17207.     
  17208.     while( flen > READLEN )
  17209.     {
  17210.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17211.         {
  17212.             printf("READ ERROR!\n");
  17213.             return;
  17214.         }
  17215.         MD5Translate( lpData, READLEN, &mdDataSum );
  17216.         MD4Translate( lpData, READLEN, &md4DataSum );
  17217.         flen -= READLEN;
  17218.         printf(".");
  17219.     }
  17220.  
  17221.     if (fread( lpData, 1, flen, file ) != flen)
  17222.     {
  17223.         printf("READ ERROR!\n");
  17224.         return;
  17225.     }
  17226.     // This is why I added the new argument to MDxPad
  17227.     // So we can pass the length of the data AND the
  17228.     // Total length of the message
  17229.     // Also it now returns the # of padding bytes added,
  17230.     // this is for files that are an exact multiple of the chunk
  17231.     // length. (Otherwise the padding isn't Translated)
  17232.     flen += MDxPad( lpData, flen, mlen );
  17233.     MD5Translate( lpData, flen, &mdDataSum );    
  17234.     MD4Translate( lpData, flen, &md4DataSum );
  17235.  
  17236.     // New step necessary because of the 'chunking' method
  17237.     MDxFinalize( &mdDataSum );
  17238.     MDxFinalize( &md4DataSum );
  17239.     
  17240.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  17241.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17242.     fclose(file);
  17243.         
  17244. }
  17245.  
  17246. void DigestString()
  17247. {
  17248.     
  17249.     //For our demo purposes, no strings bigger than 1024 :)
  17250.     unsigned char lpData[1024] = "";
  17251.     long len = 0;
  17252.     MDxSum mdDataSum;
  17253.  
  17254.     printf("Enter the string to digest: ");
  17255.     scanf("%s", &lpData );
  17256.     len = strlen(lpData);
  17257.     
  17258.     // Have to do this before the Padding...well...it's best anyway;)
  17259.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  17260.     
  17261.     // For the strings, we're gonna pad and digest the string
  17262.     // in one pass.
  17263.     MDxInit( &mdDataSum );
  17264.     MDxPad( lpData, len, len );
  17265.     
  17266.     MD5Translate( lpData, len, &mdDataSum );
  17267.         // New step necessary because of the 'chunking' method
  17268.         MDxFinalize( &mdDataSum );
  17269.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17270.     
  17271.     MDxInit( &mdDataSum );
  17272.     MD4Translate( lpData, len, &mdDataSum );    
  17273.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17274.  
  17275.     return;
  17276. }
  17277.  
  17278.  
  17279. -------------- Include
  17280.  
  17281. #ifndef __windows_h__
  17282.         typedef unsigned long DWORD;
  17283.         #define STDCALL _stdcall
  17284. #endif
  17285.  
  17286. typedef struct 
  17287. {
  17288.     DWORD dwSum[4];
  17289. }MDxSum;
  17290.  
  17291. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  17292. void STDCALL MDxInit( MDxSum * );
  17293. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  17294. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  17295. const char * STDCALL MDxGetVersion();
  17296. void STDCALL MDxFinalize( MDxSum * );
  17297.  
  17298.  
  17299.  
  17300.  
  17301. #include "mdx.h"
  17302. #include <stdlib.h>
  17303. #include <stdio.h>
  17304. #include <string.h>
  17305.  
  17306. // READLEN % 64 must = 0
  17307. #define READLEN    1048576L // 2^20, 1MB
  17308.  
  17309. void DigestFile( char * );
  17310. void DigestString();
  17311.  
  17312. void main(int argc, char *argv[])
  17313. {
  17314.     printf("%s\n\n", MDxGetVersion());
  17315.  
  17316.     if( argc > 1 )
  17317.         DigestFile( argv[1] );
  17318.     else    
  17319.         DigestString();
  17320.  
  17321. }
  17322.  
  17323. /*
  17324.     I use the 'chunk' method for processing files not because of
  17325.     limitations of my dll, but think what would happen if you
  17326.     tried to load an entire cd image into memory.
  17327. */
  17328. void DigestFile( char *szFName )
  17329. {
  17330.     FILE *file;
  17331.     void *lpData;
  17332.     long flen, mlen;
  17333.     MDxSum mdDataSum;
  17334.     MDxSum md4DataSum;
  17335.  
  17336.     // the 64 is for padding purposes
  17337.     lpData = malloc( READLEN + 64 );
  17338.     
  17339.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17340.  
  17341.     file = fopen( szFName, "rb" );
  17342.     if( file == NULL )
  17343.     {
  17344.         printf("ERROR: File not found.\n");
  17345.         return;
  17346.     }
  17347.     
  17348.     MDxInit( &mdDataSum );
  17349.     MDxInit( &md4DataSum );
  17350.     
  17351.     fseek( file, 0, SEEK_END );
  17352.     //Get the file length
  17353.     flen = mlen = ftell( file );
  17354.     fseek( file, 0, SEEK_SET );
  17355.     
  17356.     // When it takes a while to process a large file,
  17357.     // remember that for each chunk it has to run 
  17358.     // through the main translation loop 16384 times!
  17359.         
  17360.     printf("Processing %ld byte file: .", flen );
  17361.     
  17362.     while( flen > READLEN )
  17363.     {
  17364.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17365.         {
  17366.             printf("READ ERROR!\n");
  17367.             return;
  17368.         }
  17369.         MD5Translate( lpData, READLEN, &mdDataSum );
  17370.         MD4Translate( lpData, READLEN, &md4DataSum );
  17371.         flen -= READLEN;
  17372.         printf(".");
  17373.     }
  17374.  
  17375.     if (fread( lpData, 1, flen, file ) != flen)
  17376.     {
  17377.         printf("READ ERROR!\n");
  17378.         return;
  17379.     }
  17380.     // This is why I added the new argument to MDxPad
  17381.     // So we can pass the length of the data AND the
  17382.     // Total length of the message
  17383.     // Also it now returns the # of padding bytes added,
  17384.     // this is for files that are an exact multiple of the chunk
  17385.     // length. (Otherwise the padding isn't Translated)
  17386.     flen += MDxPad( lpData, flen, mlen );
  17387.     MD5Translate( lpData, flen, &mdDataSum );    
  17388.     MD4Translate( lpData, flen, &md4DataSum );
  17389.  
  17390.     // New step necessary because of the 'chunking' method
  17391.     MDxFinalize( &mdDataSum );
  17392.     MDxFinalize( &md4DataSum );
  17393.     
  17394.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  17395.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17396.     fclose(file);
  17397.         
  17398. }
  17399.  
  17400. void DigestString()
  17401. {
  17402.     
  17403.     //For our demo purposes, no strings bigger than 1024 :)
  17404.     unsigned char lpData[1024] = "";
  17405.     long len = 0;
  17406.     MDxSum mdDataSum;
  17407.  
  17408.     printf("Enter the string to digest: ");
  17409.     scanf("%s", &lpData );
  17410.     len = strlen(lpData);
  17411.     
  17412.     // Have to do this before the Padding...well...it's best anyway;)
  17413.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  17414.     
  17415.     // For the strings, we're gonna pad and digest the string
  17416.     // in one pass.
  17417.     MDxInit( &mdDataSum );
  17418.     MDxPad( lpData, len, len );
  17419.     
  17420.     MD5Translate( lpData, len, &mdDataSum );
  17421.         // New step necessary because of the 'chunking' method
  17422.         MDxFinalize( &mdDataSum );
  17423.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17424.     
  17425.     MDxInit( &mdDataSum );
  17426.     MD4Translate( lpData, len, &mdDataSum );    
  17427.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17428.  
  17429.     return;
  17430. }
  17431.  
  17432.  
  17433. -------------- Include
  17434.  
  17435. #ifndef __windows_h__
  17436.         typedef unsigned long DWORD;
  17437.         #define STDCALL _stdcall
  17438. #endif
  17439.  
  17440. typedef struct 
  17441. {
  17442.     DWORD dwSum[4];
  17443. }MDxSum;
  17444.  
  17445. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  17446. void STDCALL MDxInit( MDxSum * );
  17447. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  17448. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  17449. const char * STDCALL MDxGetVersion();
  17450. void STDCALL MDxFinalize( MDxSum * );
  17451.  
  17452.  
  17453.  
  17454.  
  17455. #include "mdx.h"
  17456. #include <stdlib.h>
  17457. #include <stdio.h>
  17458. #include <string.h>
  17459.  
  17460. // READLEN % 64 must = 0
  17461. #define READLEN    1048576L // 2^20, 1MB
  17462.  
  17463. void DigestFile( char * );
  17464. void DigestString();
  17465.  
  17466. void main(int argc, char *argv[])
  17467. {
  17468.     printf("%s\n\n", MDxGetVersion());
  17469.  
  17470.     if( argc > 1 )
  17471.         DigestFile( argv[1] );
  17472.     else    
  17473.         DigestString();
  17474.  
  17475. }
  17476.  
  17477. /*
  17478.     I use the 'chunk' method for processing files not because of
  17479.     limitations of my dll, but think what would happen if you
  17480.     tried to load an entire cd image into memory.
  17481. */
  17482. void DigestFile( char *szFName )
  17483. {
  17484.     FILE *file;
  17485.     void *lpData;
  17486.     long flen, mlen;
  17487.     MDxSum mdDataSum;
  17488.     MDxSum md4DataSum;
  17489.  
  17490.     // the 64 is for padding purposes
  17491.     lpData = malloc( READLEN + 64 );
  17492.     
  17493.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17494.  
  17495.     file = fopen( szFName, "rb" );
  17496.     if( file == NULL )
  17497.     {
  17498.         printf("ERROR: File not found.\n");
  17499.         return;
  17500.     }
  17501.     
  17502.     MDxInit( &mdDataSum );
  17503.     MDxInit( &md4DataSum );
  17504.     
  17505.     fseek( file, 0, SEEK_END );
  17506.     //Get the file length
  17507.     flen = mlen = ftell( file );
  17508.     fseek( file, 0, SEEK_SET );
  17509.     
  17510.     // When it takes a while to process a large file,
  17511.     // remember that for each chunk it has to run 
  17512.     // through the main translation loop 16384 times!
  17513.         
  17514.     printf("Processing %ld byte file: .", flen );
  17515.     
  17516.     while( flen > READLEN )
  17517.     {
  17518.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17519.         {
  17520.             printf("READ ERROR!\n");
  17521.             return;
  17522.         }
  17523.         MD5Translate( lpData, READLEN, &mdDataSum );
  17524.         MD4Translate( lpData, READLEN, &md4DataSum );
  17525.         flen -= READLEN;
  17526.         printf(".");
  17527.     }
  17528.  
  17529.     if (fread( lpData, 1, flen, file ) != flen)
  17530.     {
  17531.         printf("READ ERROR!\n");
  17532.         return;
  17533.     }
  17534.     // This is why I added the new argument to MDxPad
  17535.     // So we can pass the length of the data AND the
  17536.     // Total length of the message
  17537.     // Also it now returns the # of padding bytes added,
  17538.     // this is for files that are an exact multiple of the chunk
  17539.     // length. (Otherwise the padding isn't Translated)
  17540.     flen += MDxPad( lpData, flen, mlen );
  17541.     MD5Translate( lpData, flen, &mdDataSum );    
  17542.     MD4Translate( lpData, flen, &md4DataSum );
  17543.  
  17544.     // New step necessary because of the 'chunking' method
  17545.     MDxFinalize( &mdDataSum );
  17546.     MDxFinalize( &md4DataSum );
  17547.     
  17548.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  17549.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17550.     fclose(file);
  17551.         
  17552. }
  17553.  
  17554. void DigestString()
  17555. {
  17556.     
  17557.     //For our demo purposes, no strings bigger than 1024 :)
  17558.     unsigned char lpData[1024] = "";
  17559.     long len = 0;
  17560.     MDxSum mdDataSum;
  17561.  
  17562.     printf("Enter the string to digest: ");
  17563.     scanf("%s", &lpData );
  17564.     len = strlen(lpData);
  17565.     
  17566.     // Have to do this before the Padding...well...it's best anyway;)
  17567.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  17568.     
  17569.     // For the strings, we're gonna pad and digest the string
  17570.     // in one pass.
  17571.     MDxInit( &mdDataSum );
  17572.     MDxPad( lpData, len, len );
  17573.     
  17574.     MD5Translate( lpData, len, &mdDataSum );
  17575.         // New step necessary because of the 'chunking' method
  17576.         MDxFinalize( &mdDataSum );
  17577.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17578.     
  17579.     MDxInit( &mdDataSum );
  17580.     MD4Translate( lpData, len, &mdDataSum );    
  17581.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17582.  
  17583.     return;
  17584. }
  17585.  
  17586.  
  17587. -------------- Include
  17588.  
  17589. #ifndef __windows_h__
  17590.         typedef unsigned long DWORD;
  17591.         #define STDCALL _stdcall
  17592. #endif
  17593.  
  17594. typedef struct 
  17595. {
  17596.     DWORD dwSum[4];
  17597. }MDxSum;
  17598.  
  17599. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  17600. void STDCALL MDxInit( MDxSum * );
  17601. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  17602. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  17603. const char * STDCALL MDxGetVersion();
  17604. void STDCALL MDxFinalize( MDxSum * );
  17605.  
  17606.  
  17607.  
  17608. #include "mdx.h"
  17609. #include <stdlib.h>
  17610. #include <stdio.h>
  17611. #include <string.h>
  17612.  
  17613. // READLEN % 64 must = 0
  17614. #define READLEN    1048576L // 2^20, 1MB
  17615.  
  17616. void DigestFile( char * );
  17617. void DigestString();
  17618.  
  17619. void main(int argc, char *argv[])
  17620. {
  17621.     printf("%s\n\n", MDxGetVersion());
  17622.  
  17623.     if( argc > 1 )
  17624.         DigestFile( argv[1] );
  17625.     else    
  17626.         DigestString();
  17627.  
  17628. }
  17629.  
  17630. /*
  17631.     I use the 'chunk' method for processing files not because of
  17632.     limitations of my dll, but think what would happen if you
  17633.     tried to load an entire cd image into memory.
  17634. */
  17635. void DigestFile( char *szFName )
  17636. {
  17637.     FILE *file;
  17638.     void *lpData;
  17639.     long flen, mlen;
  17640.     MDxSum mdDataSum;
  17641.     MDxSum md4DataSum;
  17642.  
  17643.     // the 64 is for padding purposes
  17644.     lpData = malloc( READLEN + 64 );
  17645.     
  17646.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17647.  
  17648.     file = fopen( szFName, "rb" );
  17649.     if( file == NULL )
  17650.     {
  17651.         printf("ERROR: File not found.\n");
  17652.         return;
  17653.     }
  17654.     
  17655.     MDxInit( &mdDataSum );
  17656.     MDxInit( &md4DataSum );
  17657.     
  17658.     fseek( file, 0, SEEK_END );
  17659.     //Get the file length
  17660.     flen = mlen = ftell( file );
  17661.     fseek( file, 0, SEEK_SET );
  17662.     
  17663.     // When it takes a while to process a large file,
  17664.     // remember that for each chunk it has to run 
  17665.     // through the main translation loop 16384 times!
  17666.         
  17667.     printf("Processing %ld byte file: .", flen );
  17668.     
  17669.     while( flen > READLEN )
  17670.     {
  17671.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17672.         {
  17673.             printf("READ ERROR!\n");
  17674.             return;
  17675.         }
  17676.         MD5Translate( lpData, READLEN, &mdDataSum );
  17677.         MD4Translate( lpData, READLEN, &md4DataSum );
  17678.         flen -= READLEN;
  17679.         printf(".");
  17680.     }
  17681.  
  17682.     if (fread( lpData, 1, flen, file ) != flen)
  17683.     {
  17684.         printf("READ ERROR!\n");
  17685.         return;
  17686.     }
  17687.     // This is why I added the new argument to MDxPad
  17688.     // So we can pass the length of the data AND the
  17689.     // Total length of the message
  17690.     // Also it now returns the # of padding bytes added,
  17691.     // this is for files that are an exact multiple of the chunk
  17692.     // length. (Otherwise the padding isn't Translated)
  17693.     flen += MDxPad( lpData, flen, mlen );
  17694.     MD5Translate( lpData, flen, &mdDataSum );    
  17695.     MD4Translate( lpData, flen, &md4DataSum );
  17696.  
  17697.     // New step necessary because of the 'chunking' method
  17698.     MDxFinalize( &mdDataSum );
  17699.     MDxFinalize( &md4DataSum );
  17700.     
  17701.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  17702.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17703.     fclose(file);
  17704.         
  17705. }
  17706.  
  17707. void DigestString()
  17708. {
  17709.     
  17710.     //For our demo purposes, no strings bigger than 1024 :)
  17711.     unsigned char lpData[1024] = "";
  17712.     long len = 0;
  17713.     MDxSum mdDataSum;
  17714.  
  17715.     printf("Enter the string to digest: ");
  17716.     scanf("%s", &lpData );
  17717.     len = strlen(lpData);
  17718.     
  17719.     // Have to do this before the Padding...well...it's best anyway;)
  17720.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  17721.     
  17722.     // For the strings, we're gonna pad and digest the string
  17723.     // in one pass.
  17724.     MDxInit( &mdDataSum );
  17725.     MDxPad( lpData, len, len );
  17726.     
  17727.     MD5Translate( lpData, len, &mdDataSum );
  17728.         // New step necessary because of the 'chunking' method
  17729.         MDxFinalize( &mdDataSum );
  17730.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17731.     
  17732.     MDxInit( &mdDataSum );
  17733.     MD4Translate( lpData, len, &mdDataSum );    
  17734.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17735.  
  17736.     return;
  17737. }
  17738.  
  17739.  
  17740. -------------- Include
  17741.  
  17742. #ifndef __windows_h__
  17743.         typedef unsigned long DWORD;
  17744.         #define STDCALL _stdcall
  17745. #endif
  17746.  
  17747. typedef struct 
  17748. {
  17749.     DWORD dwSum[4];
  17750. }MDxSum;
  17751.  
  17752. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  17753. void STDCALL MDxInit( MDxSum * );
  17754. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  17755. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  17756. const char * STDCALL MDxGetVersion();
  17757. void STDCALL MDxFinalize( MDxSum * );
  17758.  
  17759.  
  17760.  
  17761. #include "mdx.h"
  17762. #include <stdlib.h>
  17763. #include <stdio.h>
  17764. #include <string.h>
  17765.  
  17766. // READLEN % 64 must = 0
  17767. #define READLEN    1048576L // 2^20, 1MB
  17768.  
  17769. void DigestFile( char * );
  17770. void DigestString();
  17771.  
  17772. void main(int argc, char *argv[])
  17773. {
  17774.     printf("%s\n\n", MDxGetVersion());
  17775.  
  17776.     if( argc > 1 )
  17777.         DigestFile( argv[1] );
  17778.     else    
  17779.         DigestString();
  17780.  
  17781. }
  17782.  
  17783. /*
  17784.     I use the 'chunk' method for processing files not because of
  17785.     limitations of my dll, but think what would happen if you
  17786.     tried to load an entire cd image into memory.
  17787. */
  17788. void DigestFile( char *szFName )
  17789. {
  17790.     FILE *file;
  17791.     void *lpData;
  17792.     long flen, mlen;
  17793.     MDxSum mdDataSum;
  17794.     MDxSum md4DataSum;
  17795.  
  17796.     // the 64 is for padding purposes
  17797.     lpData = malloc( READLEN + 64 );
  17798.     
  17799.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17800.  
  17801.     file = fopen( szFName, "rb" );
  17802.     if( file == NULL )
  17803.     {
  17804.         printf("ERROR: File not found.\n");
  17805.         return;
  17806.     }
  17807.     
  17808.     MDxInit( &mdDataSum );
  17809.     MDxInit( &md4DataSum );
  17810.     
  17811.     fseek( file, 0, SEEK_END );
  17812.     //Get the file length
  17813.     flen = mlen = ftell( file );
  17814.     fseek( file, 0, SEEK_SET );
  17815.     
  17816.     // When it takes a while to process a large file,
  17817.     // remember that for each chunk it has to run 
  17818.     // through the main translation loop 16384 times!
  17819.         
  17820.     printf("Processing %ld byte file: .", flen );
  17821.     
  17822.     while( flen > READLEN )
  17823.     {
  17824.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17825.         {
  17826.             printf("READ ERROR!\n");
  17827.             return;
  17828.         }
  17829.         MD5Translate( lpData, READLEN, &mdDataSum );
  17830.         MD4Translate( lpData, READLEN, &md4DataSum );
  17831.         flen -= READLEN;
  17832.         printf(".");
  17833.     }
  17834.  
  17835.     if (fread( lpData, 1, flen, file ) != flen)
  17836.     {
  17837.         printf("READ ERROR!\n");
  17838.         return;
  17839.     }
  17840.     // This is why I added the new argument to MDxPad
  17841.     // So we can pass the length of the data AND the
  17842.     // Total length of the message
  17843.     // Also it now returns the # of padding bytes added,
  17844.     // this is for files that are an exact multiple of the chunk
  17845.     // length. (Otherwise the padding isn't Translated)
  17846.     flen += MDxPad( lpData, flen, mlen );
  17847.     MD5Translate( lpData, flen, &mdDataSum );    
  17848.     MD4Translate( lpData, flen, &md4DataSum );
  17849.  
  17850.     // New step necessary because of the 'chunking' method
  17851.     MDxFinalize( &mdDataSum );
  17852.     MDxFinalize( &md4DataSum );
  17853.     
  17854.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  17855.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17856.     fclose(file);
  17857.         
  17858. }
  17859.  
  17860. void DigestString()
  17861. {
  17862.     
  17863.     //For our demo purposes, no strings bigger than 1024 :)
  17864.     unsigned char lpData[1024] = "";
  17865.     long len = 0;
  17866.     MDxSum mdDataSum;
  17867.  
  17868.     printf("Enter the string to digest: ");
  17869.     scanf("%s", &lpData );
  17870.     len = strlen(lpData);
  17871.     
  17872.     // Have to do this before the Padding...well...it's best anyway;)
  17873.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  17874.     
  17875.     // For the strings, we're gonna pad and digest the string
  17876.     // in one pass.
  17877.     MDxInit( &mdDataSum );
  17878.     MDxPad( lpData, len, len );
  17879.     
  17880.     MD5Translate( lpData, len, &mdDataSum );
  17881.         // New step necessary because of the 'chunking' method
  17882.         MDxFinalize( &mdDataSum );
  17883.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17884.     
  17885.     MDxInit( &mdDataSum );
  17886.     MD4Translate( lpData, len, &mdDataSum );    
  17887.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  17888.  
  17889.     return;
  17890. }
  17891.  
  17892.  
  17893. -------------- Include
  17894.  
  17895. #ifndef __windows_h__
  17896.         typedef unsigned long DWORD;
  17897.         #define STDCALL _stdcall
  17898. #endif
  17899.  
  17900. typedef struct 
  17901. {
  17902.     DWORD dwSum[4];
  17903. }MDxSum;
  17904.  
  17905. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  17906. void STDCALL MDxInit( MDxSum * );
  17907. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  17908. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  17909. const char * STDCALL MDxGetVersion();
  17910. void STDCALL MDxFinalize( MDxSum * );
  17911.  
  17912.  
  17913.  
  17914.  
  17915. #include "mdx.h"
  17916. #include <stdlib.h>
  17917. #include <stdio.h>
  17918. #include <string.h>
  17919.  
  17920. // READLEN % 64 must = 0
  17921. #define READLEN    1048576L // 2^20, 1MB
  17922.  
  17923. void DigestFile( char * );
  17924. void DigestString();
  17925.  
  17926. void main(int argc, char *argv[])
  17927. {
  17928.     printf("%s\n\n", MDxGetVersion());
  17929.  
  17930.     if( argc > 1 )
  17931.         DigestFile( argv[1] );
  17932.     else    
  17933.         DigestString();
  17934.  
  17935. }
  17936.  
  17937. /*
  17938.     I use the 'chunk' method for processing files not because of
  17939.     limitations of my dll, but think what would happen if you
  17940.     tried to load an entire cd image into memory.
  17941. */
  17942. void DigestFile( char *szFName )
  17943. {
  17944.     FILE *file;
  17945.     void *lpData;
  17946.     long flen, mlen;
  17947.     MDxSum mdDataSum;
  17948.     MDxSum md4DataSum;
  17949.  
  17950.     // the 64 is for padding purposes
  17951.     lpData = malloc( READLEN + 64 );
  17952.     
  17953.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  17954.  
  17955.     file = fopen( szFName, "rb" );
  17956.     if( file == NULL )
  17957.     {
  17958.         printf("ERROR: File not found.\n");
  17959.         return;
  17960.     }
  17961.     
  17962.     MDxInit( &mdDataSum );
  17963.     MDxInit( &md4DataSum );
  17964.     
  17965.     fseek( file, 0, SEEK_END );
  17966.     //Get the file length
  17967.     flen = mlen = ftell( file );
  17968.     fseek( file, 0, SEEK_SET );
  17969.     
  17970.     // When it takes a while to process a large file,
  17971.     // remember that for each chunk it has to run 
  17972.     // through the main translation loop 16384 times!
  17973.         
  17974.     printf("Processing %ld byte file: .", flen );
  17975.     
  17976.     while( flen > READLEN )
  17977.     {
  17978.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  17979.         {
  17980.             printf("READ ERROR!\n");
  17981.             return;
  17982.         }
  17983.         MD5Translate( lpData, READLEN, &mdDataSum );
  17984.         MD4Translate( lpData, READLEN, &md4DataSum );
  17985.         flen -= READLEN;
  17986.         printf(".");
  17987.     }
  17988.  
  17989.     if (fread( lpData, 1, flen, file ) != flen)
  17990.     {
  17991.         printf("READ ERROR!\n");
  17992.         return;
  17993.     }
  17994.     // This is why I added the new argument to MDxPad
  17995.     // So we can pass the length of the data AND the
  17996.     // Total length of the message
  17997.     // Also it now returns the # of padding bytes added,
  17998.     // this is for files that are an exact multiple of the chunk
  17999.     // length. (Otherwise the padding isn't Translated)
  18000.     flen += MDxPad( lpData, flen, mlen );
  18001.     MD5Translate( lpData, flen, &mdDataSum );    
  18002.     MD4Translate( lpData, flen, &md4DataSum );
  18003.  
  18004.     // New step necessary because of the 'chunking' method
  18005.     MDxFinalize( &mdDataSum );
  18006.     MDxFinalize( &md4DataSum );
  18007.     
  18008.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18009.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18010.     fclose(file);
  18011.         
  18012. }
  18013.  
  18014. void DigestString()
  18015. {
  18016.     
  18017.     //For our demo purposes, no strings bigger than 1024 :)
  18018.     unsigned char lpData[1024] = "";
  18019.     long len = 0;
  18020.     MDxSum mdDataSum;
  18021.  
  18022.     printf("Enter the string to digest: ");
  18023.     scanf("%s", &lpData );
  18024.     len = strlen(lpData);
  18025.     
  18026.     // Have to do this before the Padding...well...it's best anyway;)
  18027.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18028.     
  18029.     // For the strings, we're gonna pad and digest the string
  18030.     // in one pass.
  18031.     MDxInit( &mdDataSum );
  18032.     MDxPad( lpData, len, len );
  18033.     
  18034.     MD5Translate( lpData, len, &mdDataSum );
  18035.         // New step necessary because of the 'chunking' method
  18036.         MDxFinalize( &mdDataSum );
  18037.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18038.     
  18039.     MDxInit( &mdDataSum );
  18040.     MD4Translate( lpData, len, &mdDataSum );    
  18041.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18042.  
  18043.     return;
  18044. }
  18045.  
  18046.  
  18047. -------------- Include
  18048.  
  18049. #ifndef __windows_h__
  18050.         typedef unsigned long DWORD;
  18051.         #define STDCALL _stdcall
  18052. #endif
  18053.  
  18054. typedef struct 
  18055. {
  18056.     DWORD dwSum[4];
  18057. }MDxSum;
  18058.  
  18059. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18060. void STDCALL MDxInit( MDxSum * );
  18061. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18062. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18063. const char * STDCALL MDxGetVersion();
  18064. void STDCALL MDxFinalize( MDxSum * );
  18065.  
  18066.  
  18067.  
  18068. #include "mdx.h"
  18069. #include <stdlib.h>
  18070. #include <stdio.h>
  18071. #include <string.h>
  18072.  
  18073. // READLEN % 64 must = 0
  18074. #define READLEN    1048576L // 2^20, 1MB
  18075.  
  18076. void DigestFile( char * );
  18077. void DigestString();
  18078.  
  18079. void main(int argc, char *argv[])
  18080. {
  18081.     printf("%s\n\n", MDxGetVersion());
  18082.  
  18083.     if( argc > 1 )
  18084.         DigestFile( argv[1] );
  18085.     else    
  18086.         DigestString();
  18087.  
  18088. }
  18089.  
  18090. /*
  18091.     I use the 'chunk' method for processing files not because of
  18092.     limitations of my dll, but think what would happen if you
  18093.     tried to load an entire cd image into memory.
  18094. */
  18095. void DigestFile( char *szFName )
  18096. {
  18097.     FILE *file;
  18098.     void *lpData;
  18099.     long flen, mlen;
  18100.     MDxSum mdDataSum;
  18101.     MDxSum md4DataSum;
  18102.  
  18103.     // the 64 is for padding purposes
  18104.     lpData = malloc( READLEN + 64 );
  18105.     
  18106.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  18107.  
  18108.     file = fopen( szFName, "rb" );
  18109.     if( file == NULL )
  18110.     {
  18111.         printf("ERROR: File not found.\n");
  18112.         return;
  18113.     }
  18114.     
  18115.     MDxInit( &mdDataSum );
  18116.     MDxInit( &md4DataSum );
  18117.     
  18118.     fseek( file, 0, SEEK_END );
  18119.     //Get the file length
  18120.     flen = mlen = ftell( file );
  18121.     fseek( file, 0, SEEK_SET );
  18122.     
  18123.     // When it takes a while to process a large file,
  18124.     // remember that for each chunk it has to run 
  18125.     // through the main translation loop 16384 times!
  18126.         
  18127.     printf("Processing %ld byte file: .", flen );
  18128.     
  18129.     while( flen > READLEN )
  18130.     {
  18131.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  18132.         {
  18133.             printf("READ ERROR!\n");
  18134.             return;
  18135.         }
  18136.         MD5Translate( lpData, READLEN, &mdDataSum );
  18137.         MD4Translate( lpData, READLEN, &md4DataSum );
  18138.         flen -= READLEN;
  18139.         printf(".");
  18140.     }
  18141.  
  18142.     if (fread( lpData, 1, flen, file ) != flen)
  18143.     {
  18144.         printf("READ ERROR!\n");
  18145.         return;
  18146.     }
  18147.     // This is why I added the new argument to MDxPad
  18148.     // So we can pass the length of the data AND the
  18149.     // Total length of the message
  18150.     // Also it now returns the # of padding bytes added,
  18151.     // this is for files that are an exact multiple of the chunk
  18152.     // length. (Otherwise the padding isn't Translated)
  18153.     flen += MDxPad( lpData, flen, mlen );
  18154.     MD5Translate( lpData, flen, &mdDataSum );    
  18155.     MD4Translate( lpData, flen, &md4DataSum );
  18156.  
  18157.     // New step necessary because of the 'chunking' method
  18158.     MDxFinalize( &mdDataSum );
  18159.     MDxFinalize( &md4DataSum );
  18160.     
  18161.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18162.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18163.     fclose(file);
  18164.         
  18165. }
  18166.  
  18167. void DigestString()
  18168. {
  18169.     
  18170.     //For our demo purposes, no strings bigger than 1024 :)
  18171.     unsigned char lpData[1024] = "";
  18172.     long len = 0;
  18173.     MDxSum mdDataSum;
  18174.  
  18175.     printf("Enter the string to digest: ");
  18176.     scanf("%s", &lpData );
  18177.     len = strlen(lpData);
  18178.     
  18179.     // Have to do this before the Padding...well...it's best anyway;)
  18180.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18181.     
  18182.     // For the strings, we're gonna pad and digest the string
  18183.     // in one pass.
  18184.     MDxInit( &mdDataSum );
  18185.     MDxPad( lpData, len, len );
  18186.     
  18187.     MD5Translate( lpData, len, &mdDataSum );
  18188.         // New step necessary because of the 'chunking' method
  18189.         MDxFinalize( &mdDataSum );
  18190.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18191.     
  18192.     MDxInit( &mdDataSum );
  18193.     MD4Translate( lpData, len, &mdDataSum );    
  18194.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18195.  
  18196.     return;
  18197. }
  18198.  
  18199.  
  18200. -------------- Include
  18201.  
  18202. #ifndef __windows_h__
  18203.         typedef unsigned long DWORD;
  18204.         #define STDCALL _stdcall
  18205. #endif
  18206.  
  18207. typedef struct 
  18208. {
  18209.     DWORD dwSum[4];
  18210. }MDxSum;
  18211.  
  18212. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18213. void STDCALL MDxInit( MDxSum * );
  18214. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18215. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18216. const char * STDCALL MDxGetVersion();
  18217. void STDCALL MDxFinalize( MDxSum * );
  18218.  
  18219.  
  18220.  
  18221.  
  18222. #include "mdx.h"
  18223. #include <stdlib.h>
  18224. #include <stdio.h>
  18225. #include <string.h>
  18226.  
  18227. // READLEN % 64 must = 0
  18228. #define READLEN    1048576L // 2^20, 1MB
  18229.  
  18230. void DigestFile( char * );
  18231. void DigestString();
  18232.  
  18233. void main(int argc, char *argv[])
  18234. {
  18235.     printf("%s\n\n", MDxGetVersion());
  18236.  
  18237.     if( argc > 1 )
  18238.         DigestFile( argv[1] );
  18239.     else    
  18240.         DigestString();
  18241.  
  18242. }
  18243.  
  18244. /*
  18245.     I use the 'chunk' method for processing files not because of
  18246.     limitations of my dll, but think what would happen if you
  18247.     tried to load an entire cd image into memory.
  18248. */
  18249. void DigestFile( char *szFName )
  18250. {
  18251.     FILE *file;
  18252.     void *lpData;
  18253.     long flen, mlen;
  18254.     MDxSum mdDataSum;
  18255.     MDxSum md4DataSum;
  18256.  
  18257.     // the 64 is for padding purposes
  18258.     lpData = malloc( READLEN + 64 );
  18259.     
  18260.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  18261.  
  18262.     file = fopen( szFName, "rb" );
  18263.     if( file == NULL )
  18264.     {
  18265.         printf("ERROR: File not found.\n");
  18266.         return;
  18267.     }
  18268.     
  18269.     MDxInit( &mdDataSum );
  18270.     MDxInit( &md4DataSum );
  18271.     
  18272.     fseek( file, 0, SEEK_END );
  18273.     //Get the file length
  18274.     flen = mlen = ftell( file );
  18275.     fseek( file, 0, SEEK_SET );
  18276.     
  18277.     // When it takes a while to process a large file,
  18278.     // remember that for each chunk it has to run 
  18279.     // through the main translation loop 16384 times!
  18280.         
  18281.     printf("Processing %ld byte file: .", flen );
  18282.     
  18283.     while( flen > READLEN )
  18284.     {
  18285.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  18286.         {
  18287.             printf("READ ERROR!\n");
  18288.             return;
  18289.         }
  18290.         MD5Translate( lpData, READLEN, &mdDataSum );
  18291.         MD4Translate( lpData, READLEN, &md4DataSum );
  18292.         flen -= READLEN;
  18293.         printf(".");
  18294.     }
  18295.  
  18296.     if (fread( lpData, 1, flen, file ) != flen)
  18297.     {
  18298.         printf("READ ERROR!\n");
  18299.         return;
  18300.     }
  18301.     // This is why I added the new argument to MDxPad
  18302.     // So we can pass the length of the data AND the
  18303.     // Total length of the message
  18304.     // Also it now returns the # of padding bytes added,
  18305.     // this is for files that are an exact multiple of the chunk
  18306.     // length. (Otherwise the padding isn't Translated)
  18307.     flen += MDxPad( lpData, flen, mlen );
  18308.     MD5Translate( lpData, flen, &mdDataSum );    
  18309.     MD4Translate( lpData, flen, &md4DataSum );
  18310.  
  18311.     // New step necessary because of the 'chunking' method
  18312.     MDxFinalize( &mdDataSum );
  18313.     MDxFinalize( &md4DataSum );
  18314.     
  18315.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18316.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18317.     fclose(file);
  18318.         
  18319. }
  18320.  
  18321. void DigestString()
  18322. {
  18323.     
  18324.     //For our demo purposes, no strings bigger than 1024 :)
  18325.     unsigned char lpData[1024] = "";
  18326.     long len = 0;
  18327.     MDxSum mdDataSum;
  18328.  
  18329.     printf("Enter the string to digest: ");
  18330.     scanf("%s", &lpData );
  18331.     len = strlen(lpData);
  18332.     
  18333.     // Have to do this before the Padding...well...it's best anyway;)
  18334.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18335.     
  18336.     // For the strings, we're gonna pad and digest the string
  18337.     // in one pass.
  18338.     MDxInit( &mdDataSum );
  18339.     MDxPad( lpData, len, len );
  18340.     
  18341.     MD5Translate( lpData, len, &mdDataSum );
  18342.         // New step necessary because of the 'chunking' method
  18343.         MDxFinalize( &mdDataSum );
  18344.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18345.     
  18346.     MDxInit( &mdDataSum );
  18347.     MD4Translate( lpData, len, &mdDataSum );    
  18348.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18349.  
  18350.     return;
  18351. }
  18352.  
  18353.  
  18354. -------------- Include
  18355.  
  18356. #ifndef __windows_h__
  18357.         typedef unsigned long DWORD;
  18358.         #define STDCALL _stdcall
  18359. #endif
  18360.  
  18361. typedef struct 
  18362. {
  18363.     DWORD dwSum[4];
  18364. }MDxSum;
  18365.  
  18366. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18367. void STDCALL MDxInit( MDxSum * );
  18368. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18369. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18370. const char * STDCALL MDxGetVersion();
  18371. void STDCALL MDxFinalize( MDxSum * );
  18372.  
  18373.  
  18374.  
  18375.  
  18376. #include "mdx.h"
  18377. #include <stdlib.h>
  18378. #include <stdio.h>
  18379. #include <string.h>
  18380.  
  18381. // READLEN % 64 must = 0
  18382. #define READLEN    1048576L // 2^20, 1MB
  18383.  
  18384. void DigestFile( char * );
  18385. void DigestString();
  18386.  
  18387. void main(int argc, char *argv[])
  18388. {
  18389.     printf("%s\n\n", MDxGetVersion());
  18390.  
  18391.     if( argc > 1 )
  18392.         DigestFile( argv[1] );
  18393.     else    
  18394.         DigestString();
  18395.  
  18396. }
  18397.  
  18398. /*
  18399.     I use the 'chunk' method for processing files not because of
  18400.     limitations of my dll, but think what would happen if you
  18401.     tried to load an entire cd image into memory.
  18402. */
  18403. void DigestFile( char *szFName )
  18404. {
  18405.     FILE *file;
  18406.     void *lpData;
  18407.     long flen, mlen;
  18408.     MDxSum mdDataSum;
  18409.     MDxSum md4DataSum;
  18410.  
  18411.     // the 64 is for padding purposes
  18412.     lpData = malloc( READLEN + 64 );
  18413.     
  18414.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  18415.  
  18416.     file = fopen( szFName, "rb" );
  18417.     if( file == NULL )
  18418.     {
  18419.         printf("ERROR: File not found.\n");
  18420.         return;
  18421.     }
  18422.     
  18423.     MDxInit( &mdDataSum );
  18424.     MDxInit( &md4DataSum );
  18425.     
  18426.     fseek( file, 0, SEEK_END );
  18427.     //Get the file length
  18428.     flen = mlen = ftell( file );
  18429.     fseek( file, 0, SEEK_SET );
  18430.     
  18431.     // When it takes a while to process a large file,
  18432.     // remember that for each chunk it has to run 
  18433.     // through the main translation loop 16384 times!
  18434.         
  18435.     printf("Processing %ld byte file: .", flen );
  18436.     
  18437.     while( flen > READLEN )
  18438.     {
  18439.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  18440.         {
  18441.             printf("READ ERROR!\n");
  18442.             return;
  18443.         }
  18444.         MD5Translate( lpData, READLEN, &mdDataSum );
  18445.         MD4Translate( lpData, READLEN, &md4DataSum );
  18446.         flen -= READLEN;
  18447.         printf(".");
  18448.     }
  18449.  
  18450.     if (fread( lpData, 1, flen, file ) != flen)
  18451.     {
  18452.         printf("READ ERROR!\n");
  18453.         return;
  18454.     }
  18455.     // This is why I added the new argument to MDxPad
  18456.     // So we can pass the length of the data AND the
  18457.     // Total length of the message
  18458.     // Also it now returns the # of padding bytes added,
  18459.     // this is for files that are an exact multiple of the chunk
  18460.     // length. (Otherwise the padding isn't Translated)
  18461.     flen += MDxPad( lpData, flen, mlen );
  18462.     MD5Translate( lpData, flen, &mdDataSum );    
  18463.     MD4Translate( lpData, flen, &md4DataSum );
  18464.  
  18465.     // New step necessary because of the 'chunking' method
  18466.     MDxFinalize( &mdDataSum );
  18467.     MDxFinalize( &md4DataSum );
  18468.     
  18469.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18470.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18471.     fclose(file);
  18472.         
  18473. }
  18474.  
  18475. void DigestString()
  18476. {
  18477.     
  18478.     //For our demo purposes, no strings bigger than 1024 :)
  18479.     unsigned char lpData[1024] = "";
  18480.     long len = 0;
  18481.     MDxSum mdDataSum;
  18482.  
  18483.     printf("Enter the string to digest: ");
  18484.     scanf("%s", &lpData );
  18485.     len = strlen(lpData);
  18486.     
  18487.     // Have to do this before the Padding...well...it's best anyway;)
  18488.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18489.     
  18490.     // For the strings, we're gonna pad and digest the string
  18491.     // in one pass.
  18492.     MDxInit( &mdDataSum );
  18493.     MDxPad( lpData, len, len );
  18494.     
  18495.     MD5Translate( lpData, len, &mdDataSum );
  18496.         // New step necessary because of the 'chunking' method
  18497.         MDxFinalize( &mdDataSum );
  18498.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18499.     
  18500.     MDxInit( &mdDataSum );
  18501.     MD4Translate( lpData, len, &mdDataSum );    
  18502.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18503.  
  18504.     return;
  18505. }
  18506.  
  18507.  
  18508. -------------- Include
  18509.  
  18510. #ifndef __windows_h__
  18511.         typedef unsigned long DWORD;
  18512.         #define STDCALL _stdcall
  18513. #endif
  18514.  
  18515. typedef struct 
  18516. {
  18517.     DWORD dwSum[4];
  18518. }MDxSum;
  18519.  
  18520. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18521. void STDCALL MDxInit( MDxSum * );
  18522. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18523. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18524. const char * STDCALL MDxGetVersion();
  18525. void STDCALL MDxFinalize( MDxSum * );
  18526.  
  18527.  
  18528.  
  18529. #include "mdx.h"
  18530. #include <stdlib.h>
  18531. #include <stdio.h>
  18532. #include <string.h>
  18533.  
  18534. // READLEN % 64 must = 0
  18535. #define READLEN    1048576L // 2^20, 1MB
  18536.  
  18537. void DigestFile( char * );
  18538. void DigestString();
  18539.  
  18540. void main(int argc, char *argv[])
  18541. {
  18542.     printf("%s\n\n", MDxGetVersion());
  18543.  
  18544.     if( argc > 1 )
  18545.         DigestFile( argv[1] );
  18546.     else    
  18547.         DigestString();
  18548.  
  18549. }
  18550.  
  18551. /*
  18552.     I use the 'chunk' method for processing files not because of
  18553.     limitations of my dll, but think what would happen if you
  18554.     tried to load an entire cd image into memory.
  18555. */
  18556. void DigestFile( char *szFName )
  18557. {
  18558.     FILE *file;
  18559.     void *lpData;
  18560.     long flen, mlen;
  18561.     MDxSum mdDataSum;
  18562.     MDxSum md4DataSum;
  18563.  
  18564.     // the 64 is for padding purposes
  18565.     lpData = malloc( READLEN + 64 );
  18566.     
  18567.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  18568.  
  18569.     file = fopen( szFName, "rb" );
  18570.     if( file == NULL )
  18571.     {
  18572.         printf("ERROR: File not found.\n");
  18573.         return;
  18574.     }
  18575.     
  18576.     MDxInit( &mdDataSum );
  18577.     MDxInit( &md4DataSum );
  18578.     
  18579.     fseek( file, 0, SEEK_END );
  18580.     //Get the file length
  18581.     flen = mlen = ftell( file );
  18582.     fseek( file, 0, SEEK_SET );
  18583.     
  18584.     // When it takes a while to process a large file,
  18585.     // remember that for each chunk it has to run 
  18586.     // through the main translation loop 16384 times!
  18587.         
  18588.     printf("Processing %ld byte file: .", flen );
  18589.     
  18590.     while( flen > READLEN )
  18591.     {
  18592.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  18593.         {
  18594.             printf("READ ERROR!\n");
  18595.             return;
  18596.         }
  18597.         MD5Translate( lpData, READLEN, &mdDataSum );
  18598.         MD4Translate( lpData, READLEN, &md4DataSum );
  18599.         flen -= READLEN;
  18600.         printf(".");
  18601.     }
  18602.  
  18603.     if (fread( lpData, 1, flen, file ) != flen)
  18604.     {
  18605.         printf("READ ERROR!\n");
  18606.         return;
  18607.     }
  18608.     // This is why I added the new argument to MDxPad
  18609.     // So we can pass the length of the data AND the
  18610.     // Total length of the message
  18611.     // Also it now returns the # of padding bytes added,
  18612.     // this is for files that are an exact multiple of the chunk
  18613.     // length. (Otherwise the padding isn't Translated)
  18614.     flen += MDxPad( lpData, flen, mlen );
  18615.     MD5Translate( lpData, flen, &mdDataSum );    
  18616.     MD4Translate( lpData, flen, &md4DataSum );
  18617.  
  18618.     // New step necessary because of the 'chunking' method
  18619.     MDxFinalize( &mdDataSum );
  18620.     MDxFinalize( &md4DataSum );
  18621.     
  18622.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18623.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18624.     fclose(file);
  18625.         
  18626. }
  18627.  
  18628. void DigestString()
  18629. {
  18630.     
  18631.     //For our demo purposes, no strings bigger than 1024 :)
  18632.     unsigned char lpData[1024] = "";
  18633.     long len = 0;
  18634.     MDxSum mdDataSum;
  18635.  
  18636.     printf("Enter the string to digest: ");
  18637.     scanf("%s", &lpData );
  18638.     len = strlen(lpData);
  18639.     
  18640.     // Have to do this before the Padding...well...it's best anyway;)
  18641.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18642.     
  18643.     // For the strings, we're gonna pad and digest the string
  18644.     // in one pass.
  18645.     MDxInit( &mdDataSum );
  18646.     MDxPad( lpData, len, len );
  18647.     
  18648.     MD5Translate( lpData, len, &mdDataSum );
  18649.         // New step necessary because of the 'chunking' method
  18650.         MDxFinalize( &mdDataSum );
  18651.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18652.     
  18653.     MDxInit( &mdDataSum );
  18654.     MD4Translate( lpData, len, &mdDataSum );    
  18655.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18656.  
  18657.     return;
  18658. }
  18659.  
  18660.  
  18661. -------------- Include
  18662.  
  18663. #ifndef __windows_h__
  18664.         typedef unsigned long DWORD;
  18665.         #define STDCALL _stdcall
  18666. #endif
  18667.  
  18668. typedef struct 
  18669. {
  18670.     DWORD dwSum[4];
  18671. }MDxSum;
  18672.  
  18673. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18674. void STDCALL MDxInit( MDxSum * );
  18675. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18676. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18677. const char * STDCALL MDxGetVersion();
  18678. void STDCALL MDxFinalize( MDxSum * );
  18679.  
  18680.  
  18681. #include "mdx.h"
  18682. #include <stdlib.h>
  18683. #include <stdio.h>
  18684. #include <string.h>
  18685.  
  18686. // READLEN % 64 must = 0
  18687. #define READLEN    1048576L // 2^20, 1MB
  18688.  
  18689. void DigestFile( char * );
  18690. void DigestString();
  18691.  
  18692. void main(int argc, char *argv[])
  18693. {
  18694.     printf("%s\n\n", MDxGetVersion());
  18695.  
  18696.     if( argc > 1 )
  18697.         DigestFile( argv[1] );
  18698.     else    
  18699.         DigestString();
  18700.  
  18701. }
  18702.  
  18703. /*
  18704.     I use the 'chunk' method for processing files not because of
  18705.     limitations of my dll, but think what would happen if you
  18706.     tried to load an entire cd image into memory.
  18707. */
  18708. void DigestFile( char *szFName )
  18709. {
  18710.     FILE *file;
  18711.     void *lpData;
  18712.     long flen, mlen;
  18713.     MDxSum mdDataSum;
  18714.     MDxSum md4DataSum;
  18715.  
  18716.     // the 64 is for padding purposes
  18717.     lpData = malloc( READLEN + 64 );
  18718.     
  18719.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  18720.  
  18721.     file = fopen( szFName, "rb" );
  18722.     if( file == NULL )
  18723.     {
  18724.         printf("ERROR: File not found.\n");
  18725.         return;
  18726.     }
  18727.     
  18728.     MDxInit( &mdDataSum );
  18729.     MDxInit( &md4DataSum );
  18730.     
  18731.     fseek( file, 0, SEEK_END );
  18732.     //Get the file length
  18733.     flen = mlen = ftell( file );
  18734.     fseek( file, 0, SEEK_SET );
  18735.     
  18736.     // When it takes a while to process a large file,
  18737.     // remember that for each chunk it has to run 
  18738.     // through the main translation loop 16384 times!
  18739.         
  18740.     printf("Processing %ld byte file: .", flen );
  18741.     
  18742.     while( flen > READLEN )
  18743.     {
  18744.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  18745.         {
  18746.             printf("READ ERROR!\n");
  18747.             return;
  18748.         }
  18749.         MD5Translate( lpData, READLEN, &mdDataSum );
  18750.         MD4Translate( lpData, READLEN, &md4DataSum );
  18751.         flen -= READLEN;
  18752.         printf(".");
  18753.     }
  18754.  
  18755.     if (fread( lpData, 1, flen, file ) != flen)
  18756.     {
  18757.         printf("READ ERROR!\n");
  18758.         return;
  18759.     }
  18760.     // This is why I added the new argument to MDxPad
  18761.     // So we can pass the length of the data AND the
  18762.     // Total length of the message
  18763.     // Also it now returns the # of padding bytes added,
  18764.     // this is for files that are an exact multiple of the chunk
  18765.     // length. (Otherwise the padding isn't Translated)
  18766.     flen += MDxPad( lpData, flen, mlen );
  18767.     MD5Translate( lpData, flen, &mdDataSum );    
  18768.     MD4Translate( lpData, flen, &md4DataSum );
  18769.  
  18770.     // New step necessary because of the 'chunking' method
  18771.     MDxFinalize( &mdDataSum );
  18772.     MDxFinalize( &md4DataSum );
  18773.     
  18774.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18775.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18776.     fclose(file);
  18777.         
  18778. }
  18779.  
  18780. void DigestString()
  18781. {
  18782.     
  18783.     //For our demo purposes, no strings bigger than 1024 :)
  18784.     unsigned char lpData[1024] = "";
  18785.     long len = 0;
  18786.     MDxSum mdDataSum;
  18787.  
  18788.     printf("Enter the string to digest: ");
  18789.     scanf("%s", &lpData );
  18790.     len = strlen(lpData);
  18791.     
  18792.     // Have to do this before the Padding...well...it's best anyway;)
  18793.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18794.     
  18795.     // For the strings, we're gonna pad and digest the string
  18796.     // in one pass.
  18797.     MDxInit( &mdDataSum );
  18798.     MDxPad( lpData, len, len );
  18799.     
  18800.     MD5Translate( lpData, len, &mdDataSum );
  18801.         // New step necessary because of the 'chunking' method
  18802.         MDxFinalize( &mdDataSum );
  18803.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18804.     
  18805.     MDxInit( &mdDataSum );
  18806.     MD4Translate( lpData, len, &mdDataSum );    
  18807.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18808.  
  18809.     return;
  18810. }
  18811.  
  18812.  
  18813. -------------- Include
  18814.  
  18815. #ifndef __windows_h__
  18816.         typedef unsigned long DWORD;
  18817.         #define STDCALL _stdcall
  18818. #endif
  18819.  
  18820. typedef struct 
  18821. {
  18822.     DWORD dwSum[4];
  18823. }MDxSum;
  18824.  
  18825. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18826. void STDCALL MDxInit( MDxSum * );
  18827. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18828. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18829. const char * STDCALL MDxGetVersion();
  18830. void STDCALL MDxFinalize( MDxSum * );
  18831.  
  18832.  
  18833.  
  18834. #include "mdx.h"
  18835. #include <stdlib.h>
  18836. #include <stdio.h>
  18837. #include <string.h>
  18838.  
  18839. // READLEN % 64 must = 0
  18840. #define READLEN    1048576L // 2^20, 1MB
  18841.  
  18842. void DigestFile( char * );
  18843. void DigestString();
  18844.  
  18845. void main(int argc, char *argv[])
  18846. {
  18847.     printf("%s\n\n", MDxGetVersion());
  18848.  
  18849.     if( argc > 1 )
  18850.         DigestFile( argv[1] );
  18851.     else    
  18852.         DigestString();
  18853.  
  18854. }
  18855.  
  18856. /*
  18857.     I use the 'chunk' method for processing files not because of
  18858.     limitations of my dll, but think what would happen if you
  18859.     tried to load an entire cd image into memory.
  18860. */
  18861. void DigestFile( char *szFName )
  18862. {
  18863.     FILE *file;
  18864.     void *lpData;
  18865.     long flen, mlen;
  18866.     MDxSum mdDataSum;
  18867.     MDxSum md4DataSum;
  18868.  
  18869.     // the 64 is for padding purposes
  18870.     lpData = malloc( READLEN + 64 );
  18871.     
  18872.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  18873.  
  18874.     file = fopen( szFName, "rb" );
  18875.     if( file == NULL )
  18876.     {
  18877.         printf("ERROR: File not found.\n");
  18878.         return;
  18879.     }
  18880.     
  18881.     MDxInit( &mdDataSum );
  18882.     MDxInit( &md4DataSum );
  18883.     
  18884.     fseek( file, 0, SEEK_END );
  18885.     //Get the file length
  18886.     flen = mlen = ftell( file );
  18887.     fseek( file, 0, SEEK_SET );
  18888.     
  18889.     // When it takes a while to process a large file,
  18890.     // remember that for each chunk it has to run 
  18891.     // through the main translation loop 16384 times!
  18892.         
  18893.     printf("Processing %ld byte file: .", flen );
  18894.     
  18895.     while( flen > READLEN )
  18896.     {
  18897.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  18898.         {
  18899.             printf("READ ERROR!\n");
  18900.             return;
  18901.         }
  18902.         MD5Translate( lpData, READLEN, &mdDataSum );
  18903.         MD4Translate( lpData, READLEN, &md4DataSum );
  18904.         flen -= READLEN;
  18905.         printf(".");
  18906.     }
  18907.  
  18908.     if (fread( lpData, 1, flen, file ) != flen)
  18909.     {
  18910.         printf("READ ERROR!\n");
  18911.         return;
  18912.     }
  18913.     // This is why I added the new argument to MDxPad
  18914.     // So we can pass the length of the data AND the
  18915.     // Total length of the message
  18916.     // Also it now returns the # of padding bytes added,
  18917.     // this is for files that are an exact multiple of the chunk
  18918.     // length. (Otherwise the padding isn't Translated)
  18919.     flen += MDxPad( lpData, flen, mlen );
  18920.     MD5Translate( lpData, flen, &mdDataSum );    
  18921.     MD4Translate( lpData, flen, &md4DataSum );
  18922.  
  18923.     // New step necessary because of the 'chunking' method
  18924.     MDxFinalize( &mdDataSum );
  18925.     MDxFinalize( &md4DataSum );
  18926.     
  18927.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  18928.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18929.     fclose(file);
  18930.         
  18931. }
  18932.  
  18933. void DigestString()
  18934. {
  18935.     
  18936.     //For our demo purposes, no strings bigger than 1024 :)
  18937.     unsigned char lpData[1024] = "";
  18938.     long len = 0;
  18939.     MDxSum mdDataSum;
  18940.  
  18941.     printf("Enter the string to digest: ");
  18942.     scanf("%s", &lpData );
  18943.     len = strlen(lpData);
  18944.     
  18945.     // Have to do this before the Padding...well...it's best anyway;)
  18946.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  18947.     
  18948.     // For the strings, we're gonna pad and digest the string
  18949.     // in one pass.
  18950.     MDxInit( &mdDataSum );
  18951.     MDxPad( lpData, len, len );
  18952.     
  18953.     MD5Translate( lpData, len, &mdDataSum );
  18954.         // New step necessary because of the 'chunking' method
  18955.         MDxFinalize( &mdDataSum );
  18956.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18957.     
  18958.     MDxInit( &mdDataSum );
  18959.     MD4Translate( lpData, len, &mdDataSum );    
  18960.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  18961.  
  18962.     return;
  18963. }
  18964.  
  18965.  
  18966. -------------- Include
  18967.  
  18968. #ifndef __windows_h__
  18969.         typedef unsigned long DWORD;
  18970.         #define STDCALL _stdcall
  18971. #endif
  18972.  
  18973. typedef struct 
  18974. {
  18975.     DWORD dwSum[4];
  18976. }MDxSum;
  18977.  
  18978. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  18979. void STDCALL MDxInit( MDxSum * );
  18980. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  18981. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  18982. const char * STDCALL MDxGetVersion();
  18983. void STDCALL MDxFinalize( MDxSum * );
  18984.  
  18985.  
  18986.  
  18987. #include "mdx.h"
  18988. #include <stdlib.h>
  18989. #include <stdio.h>
  18990. #include <string.h>
  18991.  
  18992. // READLEN % 64 must = 0
  18993. #define READLEN    1048576L // 2^20, 1MB
  18994.  
  18995. void DigestFile( char * );
  18996. void DigestString();
  18997.  
  18998. void main(int argc, char *argv[])
  18999. {
  19000.     printf("%s\n\n", MDxGetVersion());
  19001.  
  19002.     if( argc > 1 )
  19003.         DigestFile( argv[1] );
  19004.     else    
  19005.         DigestString();
  19006.  
  19007. }
  19008.  
  19009. /*
  19010.     I use the 'chunk' method for processing files not because of
  19011.     limitations of my dll, but think what would happen if you
  19012.     tried to load an entire cd image into memory.
  19013. */
  19014. void DigestFile( char *szFName )
  19015. {
  19016.     FILE *file;
  19017.     void *lpData;
  19018.     long flen, mlen;
  19019.     MDxSum mdDataSum;
  19020.     MDxSum md4DataSum;
  19021.  
  19022.     // the 64 is for padding purposes
  19023.     lpData = malloc( READLEN + 64 );
  19024.     
  19025.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19026.  
  19027.     file = fopen( szFName, "rb" );
  19028.     if( file == NULL )
  19029.     {
  19030.         printf("ERROR: File not found.\n");
  19031.         return;
  19032.     }
  19033.     
  19034.     MDxInit( &mdDataSum );
  19035.     MDxInit( &md4DataSum );
  19036.     
  19037.     fseek( file, 0, SEEK_END );
  19038.     //Get the file length
  19039.     flen = mlen = ftell( file );
  19040.     fseek( file, 0, SEEK_SET );
  19041.     
  19042.     // When it takes a while to process a large file,
  19043.     // remember that for each chunk it has to run 
  19044.     // through the main translation loop 16384 times!
  19045.         
  19046.     printf("Processing %ld byte file: .", flen );
  19047.     
  19048.     while( flen > READLEN )
  19049.     {
  19050.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19051.         {
  19052.             printf("READ ERROR!\n");
  19053.             return;
  19054.         }
  19055.         MD5Translate( lpData, READLEN, &mdDataSum );
  19056.         MD4Translate( lpData, READLEN, &md4DataSum );
  19057.         flen -= READLEN;
  19058.         printf(".");
  19059.     }
  19060.  
  19061.     if (fread( lpData, 1, flen, file ) != flen)
  19062.     {
  19063.         printf("READ ERROR!\n");
  19064.         return;
  19065.     }
  19066.     // This is why I added the new argument to MDxPad
  19067.     // So we can pass the length of the data AND the
  19068.     // Total length of the message
  19069.     // Also it now returns the # of padding bytes added,
  19070.     // this is for files that are an exact multiple of the chunk
  19071.     // length. (Otherwise the padding isn't Translated)
  19072.     flen += MDxPad( lpData, flen, mlen );
  19073.     MD5Translate( lpData, flen, &mdDataSum );    
  19074.     MD4Translate( lpData, flen, &md4DataSum );
  19075.  
  19076.     // New step necessary because of the 'chunking' method
  19077.     MDxFinalize( &mdDataSum );
  19078.     MDxFinalize( &md4DataSum );
  19079.     
  19080.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19081.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19082.     fclose(file);
  19083.         
  19084. }
  19085.  
  19086. void DigestString()
  19087. {
  19088.     
  19089.     //For our demo purposes, no strings bigger than 1024 :)
  19090.     unsigned char lpData[1024] = "";
  19091.     long len = 0;
  19092.     MDxSum mdDataSum;
  19093.  
  19094.     printf("Enter the string to digest: ");
  19095.     scanf("%s", &lpData );
  19096.     len = strlen(lpData);
  19097.     
  19098.     // Have to do this before the Padding...well...it's best anyway;)
  19099.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  19100.     
  19101.     // For the strings, we're gonna pad and digest the string
  19102.     // in one pass.
  19103.     MDxInit( &mdDataSum );
  19104.     MDxPad( lpData, len, len );
  19105.     
  19106.     MD5Translate( lpData, len, &mdDataSum );
  19107.         // New step necessary because of the 'chunking' method
  19108.         MDxFinalize( &mdDataSum );
  19109.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19110.     
  19111.     MDxInit( &mdDataSum );
  19112.     MD4Translate( lpData, len, &mdDataSum );    
  19113.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19114.  
  19115.     return;
  19116. }
  19117.  
  19118.  
  19119. -------------- Include
  19120.  
  19121. #ifndef __windows_h__
  19122.         typedef unsigned long DWORD;
  19123.         #define STDCALL _stdcall
  19124. #endif
  19125.  
  19126. typedef struct 
  19127. {
  19128.     DWORD dwSum[4];
  19129. }MDxSum;
  19130.  
  19131. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  19132. void STDCALL MDxInit( MDxSum * );
  19133. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  19134. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  19135. const char * STDCALL MDxGetVersion();
  19136. void STDCALL MDxFinalize( MDxSum * );
  19137.  
  19138.  
  19139. #include "mdx.h"
  19140. #include <stdlib.h>
  19141. #include <stdio.h>
  19142. #include <string.h>
  19143.  
  19144. // READLEN % 64 must = 0
  19145. #define READLEN    1048576L // 2^20, 1MB
  19146.  
  19147. void DigestFile( char * );
  19148. void DigestString();
  19149.  
  19150. void main(int argc, char *argv[])
  19151. {
  19152.     printf("%s\n\n", MDxGetVersion());
  19153.  
  19154.     if( argc > 1 )
  19155.         DigestFile( argv[1] );
  19156.     else    
  19157.         DigestString();
  19158.  
  19159. }
  19160.  
  19161. /*
  19162.     I use the 'chunk' method for processing files not because of
  19163.     limitations of my dll, but think what would happen if you
  19164.     tried to load an entire cd image into memory.
  19165. */
  19166. void DigestFile( char *szFName )
  19167. {
  19168.     FILE *file;
  19169.     void *lpData;
  19170.     long flen, mlen;
  19171.     MDxSum mdDataSum;
  19172.     MDxSum md4DataSum;
  19173.  
  19174.     // the 64 is for padding purposes
  19175.     lpData = malloc( READLEN + 64 );
  19176.     
  19177.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19178.  
  19179.     file = fopen( szFName, "rb" );
  19180.     if( file == NULL )
  19181.     {
  19182.         printf("ERROR: File not found.\n");
  19183.         return;
  19184.     }
  19185.     
  19186.     MDxInit( &mdDataSum );
  19187.     MDxInit( &md4DataSum );
  19188.     
  19189.     fseek( file, 0, SEEK_END );
  19190.     //Get the file length
  19191.     flen = mlen = ftell( file );
  19192.     fseek( file, 0, SEEK_SET );
  19193.     
  19194.     // When it takes a while to process a large file,
  19195.     // remember that for each chunk it has to run 
  19196.     // through the main translation loop 16384 times!
  19197.         
  19198.     printf("Processing %ld byte file: .", flen );
  19199.     
  19200.     while( flen > READLEN )
  19201.     {
  19202.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19203.         {
  19204.             printf("READ ERROR!\n");
  19205.             return;
  19206.         }
  19207.         MD5Translate( lpData, READLEN, &mdDataSum );
  19208.         MD4Translate( lpData, READLEN, &md4DataSum );
  19209.         flen -= READLEN;
  19210.         printf(".");
  19211.     }
  19212.  
  19213.     if (fread( lpData, 1, flen, file ) != flen)
  19214.     {
  19215.         printf("READ ERROR!\n");
  19216.         return;
  19217.     }
  19218.     // This is why I added the new argument to MDxPad
  19219.     // So we can pass the length of the data AND the
  19220.     // Total length of the message
  19221.     // Also it now returns the # of padding bytes added,
  19222.     // this is for files that are an exact multiple of the chunk
  19223.     // length. (Otherwise the padding isn't Translated)
  19224.     flen += MDxPad( lpData, flen, mlen );
  19225.     MD5Translate( lpData, flen, &mdDataSum );    
  19226.     MD4Translate( lpData, flen, &md4DataSum );
  19227.  
  19228.     // New step necessary because of the 'chunking' method
  19229.     MDxFinalize( &mdDataSum );
  19230.     MDxFinalize( &md4DataSum );
  19231.     
  19232.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19233.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19234.     fclose(file);
  19235.         
  19236. }
  19237.  
  19238. void DigestString()
  19239. {
  19240.     
  19241.     //For our demo purposes, no strings bigger than 1024 :)
  19242.     unsigned char lpData[1024] = "";
  19243.     long len = 0;
  19244.     MDxSum mdDataSum;
  19245.  
  19246.     printf("Enter the string to digest: ");
  19247.     scanf("%s", &lpData );
  19248.     len = strlen(lpData);
  19249.     
  19250.     // Have to do this before the Padding...well...it's best anyway;)
  19251.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  19252.     
  19253.     // For the strings, we're gonna pad and digest the string
  19254.     // in one pass.
  19255.     MDxInit( &mdDataSum );
  19256.     MDxPad( lpData, len, len );
  19257.     
  19258.     MD5Translate( lpData, len, &mdDataSum );
  19259.         // New step necessary because of the 'chunking' method
  19260.         MDxFinalize( &mdDataSum );
  19261.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19262.     
  19263.     MDxInit( &mdDataSum );
  19264.     MD4Translate( lpData, len, &mdDataSum );    
  19265.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19266.  
  19267.     return;
  19268. }
  19269.  
  19270.  
  19271. -------------- Include
  19272.  
  19273. #ifndef __windows_h__
  19274.         typedef unsigned long DWORD;
  19275.         #define STDCALL _stdcall
  19276. #endif
  19277.  
  19278. typedef struct 
  19279. {
  19280.     DWORD dwSum[4];
  19281. }MDxSum;
  19282.  
  19283. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  19284. void STDCALL MDxInit( MDxSum * );
  19285. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  19286. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  19287. const char * STDCALL MDxGetVersion();
  19288. void STDCALL MDxFinalize( MDxSum * );
  19289.  
  19290.  
  19291. #include "mdx.h"
  19292. #include <stdlib.h>
  19293. #include <stdio.h>
  19294. #include <string.h>
  19295.  
  19296. // READLEN % 64 must = 0
  19297. #define READLEN    1048576L // 2^20, 1MB
  19298.  
  19299. void DigestFile( char * );
  19300. void DigestString();
  19301.  
  19302. void main(int argc, char *argv[])
  19303. {
  19304.     printf("%s\n\n", MDxGetVersion());
  19305.  
  19306.     if( argc > 1 )
  19307.         DigestFile( argv[1] );
  19308.     else    
  19309.         DigestString();
  19310.  
  19311. }
  19312.  
  19313. /*
  19314.     I use the 'chunk' method for processing files not because of
  19315.     limitations of my dll, but think what would happen if you
  19316.     tried to load an entire cd image into memory.
  19317. */
  19318. void DigestFile( char *szFName )
  19319. {
  19320.     FILE *file;
  19321.     void *lpData;
  19322.     long flen, mlen;
  19323.     MDxSum mdDataSum;
  19324.     MDxSum md4DataSum;
  19325.  
  19326.     // the 64 is for padding purposes
  19327.     lpData = malloc( READLEN + 64 );
  19328.     
  19329.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19330.  
  19331.     file = fopen( szFName, "rb" );
  19332.     if( file == NULL )
  19333.     {
  19334.         printf("ERROR: File not found.\n");
  19335.         return;
  19336.     }
  19337.     
  19338.     MDxInit( &mdDataSum );
  19339.     MDxInit( &md4DataSum );
  19340.     
  19341.     fseek( file, 0, SEEK_END );
  19342.     //Get the file length
  19343.     flen = mlen = ftell( file );
  19344.     fseek( file, 0, SEEK_SET );
  19345.     
  19346.     // When it takes a while to process a large file,
  19347.     // remember that for each chunk it has to run 
  19348.     // through the main translation loop 16384 times!
  19349.         
  19350.     printf("Processing %ld byte file: .", flen );
  19351.     
  19352.     while( flen > READLEN )
  19353.     {
  19354.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19355.         {
  19356.             printf("READ ERROR!\n");
  19357.             return;
  19358.         }
  19359.         MD5Translate( lpData, READLEN, &mdDataSum );
  19360.         MD4Translate( lpData, READLEN, &md4DataSum );
  19361.         flen -= READLEN;
  19362.         printf(".");
  19363.     }
  19364.  
  19365.     if (fread( lpData, 1, flen, file ) != flen)
  19366.     {
  19367.         printf("READ ERROR!\n");
  19368.         return;
  19369.     }
  19370.     // This is why I added the new argument to MDxPad
  19371.     // So we can pass the length of the data AND the
  19372.     // Total length of the message
  19373.     // Also it now returns the # of padding bytes added,
  19374.     // this is for files that are an exact multiple of the chunk
  19375.     // length. (Otherwise the padding isn't Translated)
  19376.     flen += MDxPad( lpData, flen, mlen );
  19377.     MD5Translate( lpData, flen, &mdDataSum );    
  19378.     MD4Translate( lpData, flen, &md4DataSum );
  19379.  
  19380.     // New step necessary because of the 'chunking' method
  19381.     MDxFinalize( &mdDataSum );
  19382.     MDxFinalize( &md4DataSum );
  19383.     
  19384.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19385.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19386.     fclose(file);
  19387.         
  19388. }
  19389.  
  19390. void DigestString()
  19391. {
  19392.     
  19393.     //For our demo purposes, no strings bigger than 1024 :)
  19394.     unsigned char lpData[1024] = "";
  19395.     long len = 0;
  19396.     MDxSum mdDataSum;
  19397.  
  19398.     printf("Enter the string to digest: ");
  19399.     scanf("%s", &lpData );
  19400.     len = strlen(lpData);
  19401.     
  19402.     // Have to do this before the Padding...well...it's best anyway;)
  19403.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  19404.     
  19405.     // For the strings, we're gonna pad and digest the string
  19406.     // in one pass.
  19407.     MDxInit( &mdDataSum );
  19408.     MDxPad( lpData, len, len );
  19409.     
  19410.     MD5Translate( lpData, len, &mdDataSum );
  19411.         // New step necessary because of the 'chunking' method
  19412.         MDxFinalize( &mdDataSum );
  19413.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19414.     
  19415.     MDxInit( &mdDataSum );
  19416.     MD4Translate( lpData, len, &mdDataSum );    
  19417.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19418.  
  19419.     return;
  19420. }
  19421.  
  19422.  
  19423. -------------- Include
  19424.  
  19425. #ifndef __windows_h__
  19426.         typedef unsigned long DWORD;
  19427.         #define STDCALL _stdcall
  19428. #endif
  19429.  
  19430. typedef struct 
  19431. {
  19432.     DWORD dwSum[4];
  19433. }MDxSum;
  19434.  
  19435. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  19436. void STDCALL MDxInit( MDxSum * );
  19437. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  19438. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  19439. const char * STDCALL MDxGetVersion();
  19440. void STDCALL MDxFinalize( MDxSum * );
  19441.  
  19442.  
  19443.  
  19444. #include "mdx.h"
  19445. #include <stdlib.h>
  19446. #include <stdio.h>
  19447. #include <string.h>
  19448.  
  19449. // READLEN % 64 must = 0
  19450. #define READLEN    1048576L // 2^20, 1MB
  19451.  
  19452. void DigestFile( char * );
  19453. void DigestString();
  19454.  
  19455. void main(int argc, char *argv[])
  19456. {
  19457.     printf("%s\n\n", MDxGetVersion());
  19458.  
  19459.     if( argc > 1 )
  19460.         DigestFile( argv[1] );
  19461.     else    
  19462.         DigestString();
  19463.  
  19464. }
  19465.  
  19466. /*
  19467.     I use the 'chunk' method for processing files not because of
  19468.     limitations of my dll, but think what would happen if you
  19469.     tried to load an entire cd image into memory.
  19470. */
  19471. void DigestFile( char *szFName )
  19472. {
  19473.     FILE *file;
  19474.     void *lpData;
  19475.     long flen, mlen;
  19476.     MDxSum mdDataSum;
  19477.     MDxSum md4DataSum;
  19478.  
  19479.     // the 64 is for padding purposes
  19480.     lpData = malloc( READLEN + 64 );
  19481.     
  19482.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19483.  
  19484.     file = fopen( szFName, "rb" );
  19485.     if( file == NULL )
  19486.     {
  19487.         printf("ERROR: File not found.\n");
  19488.         return;
  19489.     }
  19490.     
  19491.     MDxInit( &mdDataSum );
  19492.     MDxInit( &md4DataSum );
  19493.     
  19494.     fseek( file, 0, SEEK_END );
  19495.     //Get the file length
  19496.     flen = mlen = ftell( file );
  19497.     fseek( file, 0, SEEK_SET );
  19498.     
  19499.     // When it takes a while to process a large file,
  19500.     // remember that for each chunk it has to run 
  19501.     // through the main translation loop 16384 times!
  19502.         
  19503.     printf("Processing %ld byte file: .", flen );
  19504.     
  19505.     while( flen > READLEN )
  19506.     {
  19507.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19508.         {
  19509.             printf("READ ERROR!\n");
  19510.             return;
  19511.         }
  19512.         MD5Translate( lpData, READLEN, &mdDataSum );
  19513.         MD4Translate( lpData, READLEN, &md4DataSum );
  19514.         flen -= READLEN;
  19515.         printf(".");
  19516.     }
  19517.  
  19518.     if (fread( lpData, 1, flen, file ) != flen)
  19519.     {
  19520.         printf("READ ERROR!\n");
  19521.         return;
  19522.     }
  19523.     // This is why I added the new argument to MDxPad
  19524.     // So we can pass the length of the data AND the
  19525.     // Total length of the message
  19526.     // Also it now returns the # of padding bytes added,
  19527.     // this is for files that are an exact multiple of the chunk
  19528.     // length. (Otherwise the padding isn't Translated)
  19529.     flen += MDxPad( lpData, flen, mlen );
  19530.     MD5Translate( lpData, flen, &mdDataSum );    
  19531.     MD4Translate( lpData, flen, &md4DataSum );
  19532.  
  19533.     // New step necessary because of the 'chunking' method
  19534.     MDxFinalize( &mdDataSum );
  19535.     MDxFinalize( &md4DataSum );
  19536.     
  19537.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19538.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19539.     fclose(file);
  19540.         
  19541. }
  19542.  
  19543. void DigestString()
  19544. {
  19545.     
  19546.     //For our demo purposes, no strings bigger than 1024 :)
  19547.     unsigned char lpData[1024] = "";
  19548.     long len = 0;
  19549.     MDxSum mdDataSum;
  19550.  
  19551.     printf("Enter the string to digest: ");
  19552.     scanf("%s", &lpData );
  19553.     len = strlen(lpData);
  19554.     
  19555.     // Have to do this before the Padding...well...it's best anyway;)
  19556.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  19557.     
  19558.     // For the strings, we're gonna pad and digest the string
  19559.     // in one pass.
  19560.     MDxInit( &mdDataSum );
  19561.     MDxPad( lpData, len, len );
  19562.     
  19563.     MD5Translate( lpData, len, &mdDataSum );
  19564.         // New step necessary because of the 'chunking' method
  19565.         MDxFinalize( &mdDataSum );
  19566.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19567.     
  19568.     MDxInit( &mdDataSum );
  19569.     MD4Translate( lpData, len, &mdDataSum );    
  19570.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19571.  
  19572.     return;
  19573. }
  19574.  
  19575.  
  19576. -------------- Include
  19577.  
  19578. #ifndef __windows_h__
  19579.         typedef unsigned long DWORD;
  19580.         #define STDCALL _stdcall
  19581. #endif
  19582.  
  19583. typedef struct 
  19584. {
  19585.     DWORD dwSum[4];
  19586. }MDxSum;
  19587.  
  19588. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  19589. void STDCALL MDxInit( MDxSum * );
  19590. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  19591. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  19592. const char * STDCALL MDxGetVersion();
  19593. void STDCALL MDxFinalize( MDxSum * );
  19594.  
  19595.  
  19596.  
  19597. #include "mdx.h"
  19598. #include <stdlib.h>
  19599. #include <stdio.h>
  19600. #include <string.h>
  19601.  
  19602. // READLEN % 64 must = 0
  19603. #define READLEN    1048576L // 2^20, 1MB
  19604.  
  19605. void DigestFile( char * );
  19606. void DigestString();
  19607.  
  19608. void main(int argc, char *argv[])
  19609. {
  19610.     printf("%s\n\n", MDxGetVersion());
  19611.  
  19612.     if( argc > 1 )
  19613.         DigestFile( argv[1] );
  19614.     else    
  19615.         DigestString();
  19616.  
  19617. }
  19618.  
  19619. /*
  19620.     I use the 'chunk' method for processing files not because of
  19621.     limitations of my dll, but think what would happen if you
  19622.     tried to load an entire cd image into memory.
  19623. */
  19624. void DigestFile( char *szFName )
  19625. {
  19626.     FILE *file;
  19627.     void *lpData;
  19628.     long flen, mlen;
  19629.     MDxSum mdDataSum;
  19630.     MDxSum md4DataSum;
  19631.  
  19632.     // the 64 is for padding purposes
  19633.     lpData = malloc( READLEN + 64 );
  19634.     
  19635.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19636.  
  19637.     file = fopen( szFName, "rb" );
  19638.     if( file == NULL )
  19639.     {
  19640.         printf("ERROR: File not found.\n");
  19641.         return;
  19642.     }
  19643.     
  19644.     MDxInit( &mdDataSum );
  19645.     MDxInit( &md4DataSum );
  19646.     
  19647.     fseek( file, 0, SEEK_END );
  19648.     //Get the file length
  19649.     flen = mlen = ftell( file );
  19650.     fseek( file, 0, SEEK_SET );
  19651.     
  19652.     // When it takes a while to process a large file,
  19653.     // remember that for each chunk it has to run 
  19654.     // through the main translation loop 16384 times!
  19655.         
  19656.     printf("Processing %ld byte file: .", flen );
  19657.     
  19658.     while( flen > READLEN )
  19659.     {
  19660.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19661.         {
  19662.             printf("READ ERROR!\n");
  19663.             return;
  19664.         }
  19665.         MD5Translate( lpData, READLEN, &mdDataSum );
  19666.         MD4Translate( lpData, READLEN, &md4DataSum );
  19667.         flen -= READLEN;
  19668.         printf(".");
  19669.     }
  19670.  
  19671.     if (fread( lpData, 1, flen, file ) != flen)
  19672.     {
  19673.         printf("READ ERROR!\n");
  19674.         return;
  19675.     }
  19676.     // This is why I added the new argument to MDxPad
  19677.     // So we can pass the length of the data AND the
  19678.     // Total length of the message
  19679.     // Also it now returns the # of padding bytes added,
  19680.     // this is for files that are an exact multiple of the chunk
  19681.     // length. (Otherwise the padding isn't Translated)
  19682.     flen += MDxPad( lpData, flen, mlen );
  19683.     MD5Translate( lpData, flen, &mdDataSum );    
  19684.     MD4Translate( lpData, flen, &md4DataSum );
  19685.  
  19686.     // New step necessary because of the 'chunking' method
  19687.     MDxFinalize( &mdDataSum );
  19688.     MDxFinalize( &md4DataSum );
  19689.     
  19690.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19691.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19692.     fclose(file);
  19693.         
  19694. }
  19695.  
  19696. void DigestString()
  19697. {
  19698.     
  19699.     //For our demo purposes, no strings bigger than 1024 :)
  19700.     unsigned char lpData[1024] = "";
  19701.     long len = 0;
  19702.     MDxSum mdDataSum;
  19703.  
  19704.     printf("Enter the string to digest: ");
  19705.     scanf("%s", &lpData );
  19706.     len = strlen(lpData);
  19707.     
  19708.     // Have to do this before the Padding...well...it's best anyway;)
  19709.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  19710.     
  19711.     // For the strings, we're gonna pad and digest the string
  19712.     // in one pass.
  19713.     MDxInit( &mdDataSum );
  19714.     MDxPad( lpData, len, len );
  19715.     
  19716.     MD5Translate( lpData, len, &mdDataSum );
  19717.         // New step necessary because of the 'chunking' method
  19718.         MDxFinalize( &mdDataSum );
  19719.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19720.     
  19721.     MDxInit( &mdDataSum );
  19722.     MD4Translate( lpData, len, &mdDataSum );    
  19723.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19724.  
  19725.     return;
  19726. }
  19727.  
  19728.  
  19729. -------------- Include
  19730.  
  19731. #ifndef __windows_h__
  19732.         typedef unsigned long DWORD;
  19733.         #define STDCALL _stdcall
  19734. #endif
  19735.  
  19736. typedef struct 
  19737. {
  19738.     DWORD dwSum[4];
  19739. }MDxSum;
  19740.  
  19741. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  19742. void STDCALL MDxInit( MDxSum * );
  19743. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  19744. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  19745. const char * STDCALL MDxGetVersion();
  19746. void STDCALL MDxFinalize( MDxSum * );
  19747.  
  19748.  
  19749.  
  19750. #include "mdx.h"
  19751. #include <stdlib.h>
  19752. #include <stdio.h>
  19753. #include <string.h>
  19754.  
  19755. // READLEN % 64 must = 0
  19756. #define READLEN    1048576L // 2^20, 1MB
  19757.  
  19758. void DigestFile( char * );
  19759. void DigestString();
  19760.  
  19761. void main(int argc, char *argv[])
  19762. {
  19763.     printf("%s\n\n", MDxGetVersion());
  19764.  
  19765.     if( argc > 1 )
  19766.         DigestFile( argv[1] );
  19767.     else    
  19768.         DigestString();
  19769.  
  19770. }
  19771.  
  19772. /*
  19773.     I use the 'chunk' method for processing files not because of
  19774.     limitations of my dll, but think what would happen if you
  19775.     tried to load an entire cd image into memory.
  19776. */
  19777. void DigestFile( char *szFName )
  19778. {
  19779.     FILE *file;
  19780.     void *lpData;
  19781.     long flen, mlen;
  19782.     MDxSum mdDataSum;
  19783.     MDxSum md4DataSum;
  19784.  
  19785.     // the 64 is for padding purposes
  19786.     lpData = malloc( READLEN + 64 );
  19787.     
  19788.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19789.  
  19790.     file = fopen( szFName, "rb" );
  19791.     if( file == NULL )
  19792.     {
  19793.         printf("ERROR: File not found.\n");
  19794.         return;
  19795.     }
  19796.     
  19797.     MDxInit( &mdDataSum );
  19798.     MDxInit( &md4DataSum );
  19799.     
  19800.     fseek( file, 0, SEEK_END );
  19801.     //Get the file length
  19802.     flen = mlen = ftell( file );
  19803.     fseek( file, 0, SEEK_SET );
  19804.     
  19805.     // When it takes a while to process a large file,
  19806.     // remember that for each chunk it has to run 
  19807.     // through the main translation loop 16384 times!
  19808.         
  19809.     printf("Processing %ld byte file: .", flen );
  19810.     
  19811.     while( flen > READLEN )
  19812.     {
  19813.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19814.         {
  19815.             printf("READ ERROR!\n");
  19816.             return;
  19817.         }
  19818.         MD5Translate( lpData, READLEN, &mdDataSum );
  19819.         MD4Translate( lpData, READLEN, &md4DataSum );
  19820.         flen -= READLEN;
  19821.         printf(".");
  19822.     }
  19823.  
  19824.     if (fread( lpData, 1, flen, file ) != flen)
  19825.     {
  19826.         printf("READ ERROR!\n");
  19827.         return;
  19828.     }
  19829.     // This is why I added the new argument to MDxPad
  19830.     // So we can pass the length of the data AND the
  19831.     // Total length of the message
  19832.     // Also it now returns the # of padding bytes added,
  19833.     // this is for files that are an exact multiple of the chunk
  19834.     // length. (Otherwise the padding isn't Translated)
  19835.     flen += MDxPad( lpData, flen, mlen );
  19836.     MD5Translate( lpData, flen, &mdDataSum );    
  19837.     MD4Translate( lpData, flen, &md4DataSum );
  19838.  
  19839.     // New step necessary because of the 'chunking' method
  19840.     MDxFinalize( &mdDataSum );
  19841.     MDxFinalize( &md4DataSum );
  19842.     
  19843.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19844.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19845.     fclose(file);
  19846.         
  19847. }
  19848.  
  19849. void DigestString()
  19850. {
  19851.     
  19852.     //For our demo purposes, no strings bigger than 1024 :)
  19853.     unsigned char lpData[1024] = "";
  19854.     long len = 0;
  19855.     MDxSum mdDataSum;
  19856.  
  19857.     printf("Enter the string to digest: ");
  19858.     scanf("%s", &lpData );
  19859.     len = strlen(lpData);
  19860.     
  19861.     // Have to do this before the Padding...well...it's best anyway;)
  19862.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  19863.     
  19864.     // For the strings, we're gonna pad and digest the string
  19865.     // in one pass.
  19866.     MDxInit( &mdDataSum );
  19867.     MDxPad( lpData, len, len );
  19868.     
  19869.     MD5Translate( lpData, len, &mdDataSum );
  19870.         // New step necessary because of the 'chunking' method
  19871.         MDxFinalize( &mdDataSum );
  19872.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19873.     
  19874.     MDxInit( &mdDataSum );
  19875.     MD4Translate( lpData, len, &mdDataSum );    
  19876.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19877.  
  19878.     return;
  19879. }
  19880.  
  19881.  
  19882. -------------- Include
  19883.  
  19884. #ifndef __windows_h__
  19885.         typedef unsigned long DWORD;
  19886.         #define STDCALL _stdcall
  19887. #endif
  19888.  
  19889. typedef struct 
  19890. {
  19891.     DWORD dwSum[4];
  19892. }MDxSum;
  19893.  
  19894. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  19895. void STDCALL MDxInit( MDxSum * );
  19896. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  19897. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  19898. const char * STDCALL MDxGetVersion();
  19899. void STDCALL MDxFinalize( MDxSum * );
  19900.  
  19901.  
  19902.  
  19903. #include "mdx.h"
  19904. #include <stdlib.h>
  19905. #include <stdio.h>
  19906. #include <string.h>
  19907.  
  19908. // READLEN % 64 must = 0
  19909. #define READLEN    1048576L // 2^20, 1MB
  19910.  
  19911. void DigestFile( char * );
  19912. void DigestString();
  19913.  
  19914. void main(int argc, char *argv[])
  19915. {
  19916.     printf("%s\n\n", MDxGetVersion());
  19917.  
  19918.     if( argc > 1 )
  19919.         DigestFile( argv[1] );
  19920.     else    
  19921.         DigestString();
  19922.  
  19923. }
  19924.  
  19925. /*
  19926.     I use the 'chunk' method for processing files not because of
  19927.     limitations of my dll, but think what would happen if you
  19928.     tried to load an entire cd image into memory.
  19929. */
  19930. void DigestFile( char *szFName )
  19931. {
  19932.     FILE *file;
  19933.     void *lpData;
  19934.     long flen, mlen;
  19935.     MDxSum mdDataSum;
  19936.     MDxSum md4DataSum;
  19937.  
  19938.     // the 64 is for padding purposes
  19939.     lpData = malloc( READLEN + 64 );
  19940.     
  19941.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  19942.  
  19943.     file = fopen( szFName, "rb" );
  19944.     if( file == NULL )
  19945.     {
  19946.         printf("ERROR: File not found.\n");
  19947.         return;
  19948.     }
  19949.     
  19950.     MDxInit( &mdDataSum );
  19951.     MDxInit( &md4DataSum );
  19952.     
  19953.     fseek( file, 0, SEEK_END );
  19954.     //Get the file length
  19955.     flen = mlen = ftell( file );
  19956.     fseek( file, 0, SEEK_SET );
  19957.     
  19958.     // When it takes a while to process a large file,
  19959.     // remember that for each chunk it has to run 
  19960.     // through the main translation loop 16384 times!
  19961.         
  19962.     printf("Processing %ld byte file: .", flen );
  19963.     
  19964.     while( flen > READLEN )
  19965.     {
  19966.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  19967.         {
  19968.             printf("READ ERROR!\n");
  19969.             return;
  19970.         }
  19971.         MD5Translate( lpData, READLEN, &mdDataSum );
  19972.         MD4Translate( lpData, READLEN, &md4DataSum );
  19973.         flen -= READLEN;
  19974.         printf(".");
  19975.     }
  19976.  
  19977.     if (fread( lpData, 1, flen, file ) != flen)
  19978.     {
  19979.         printf("READ ERROR!\n");
  19980.         return;
  19981.     }
  19982.     // This is why I added the new argument to MDxPad
  19983.     // So we can pass the length of the data AND the
  19984.     // Total length of the message
  19985.     // Also it now returns the # of padding bytes added,
  19986.     // this is for files that are an exact multiple of the chunk
  19987.     // length. (Otherwise the padding isn't Translated)
  19988.     flen += MDxPad( lpData, flen, mlen );
  19989.     MD5Translate( lpData, flen, &mdDataSum );    
  19990.     MD4Translate( lpData, flen, &md4DataSum );
  19991.  
  19992.     // New step necessary because of the 'chunking' method
  19993.     MDxFinalize( &mdDataSum );
  19994.     MDxFinalize( &md4DataSum );
  19995.     
  19996.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  19997.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  19998.     fclose(file);
  19999.         
  20000. }
  20001.  
  20002. void DigestString()
  20003. {
  20004.     
  20005.     //For our demo purposes, no strings bigger than 1024 :)
  20006.     unsigned char lpData[1024] = "";
  20007.     long len = 0;
  20008.     MDxSum mdDataSum;
  20009.  
  20010.     printf("Enter the string to digest: ");
  20011.     scanf("%s", &lpData );
  20012.     len = strlen(lpData);
  20013.     
  20014.     // Have to do this before the Padding...well...it's best anyway;)
  20015.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20016.     
  20017.     // For the strings, we're gonna pad and digest the string
  20018.     // in one pass.
  20019.     MDxInit( &mdDataSum );
  20020.     MDxPad( lpData, len, len );
  20021.     
  20022.     MD5Translate( lpData, len, &mdDataSum );
  20023.         // New step necessary because of the 'chunking' method
  20024.         MDxFinalize( &mdDataSum );
  20025.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20026.     
  20027.     MDxInit( &mdDataSum );
  20028.     MD4Translate( lpData, len, &mdDataSum );    
  20029.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20030.  
  20031.     return;
  20032. }
  20033.  
  20034.  
  20035. -------------- Include
  20036.  
  20037. #ifndef __windows_h__
  20038.         typedef unsigned long DWORD;
  20039.         #define STDCALL _stdcall
  20040. #endif
  20041.  
  20042. typedef struct 
  20043. {
  20044.     DWORD dwSum[4];
  20045. }MDxSum;
  20046.  
  20047. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20048. void STDCALL MDxInit( MDxSum * );
  20049. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20050. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20051. const char * STDCALL MDxGetVersion();
  20052. void STDCALL MDxFinalize( MDxSum * );
  20053.  
  20054.  
  20055.  
  20056. #include "mdx.h"
  20057. #include <stdlib.h>
  20058. #include <stdio.h>
  20059. #include <string.h>
  20060.  
  20061. // READLEN % 64 must = 0
  20062. #define READLEN    1048576L // 2^20, 1MB
  20063.  
  20064. void DigestFile( char * );
  20065. void DigestString();
  20066.  
  20067. void main(int argc, char *argv[])
  20068. {
  20069.     printf("%s\n\n", MDxGetVersion());
  20070.  
  20071.     if( argc > 1 )
  20072.         DigestFile( argv[1] );
  20073.     else    
  20074.         DigestString();
  20075.  
  20076. }
  20077.  
  20078. /*
  20079.     I use the 'chunk' method for processing files not because of
  20080.     limitations of my dll, but think what would happen if you
  20081.     tried to load an entire cd image into memory.
  20082. */
  20083. void DigestFile( char *szFName )
  20084. {
  20085.     FILE *file;
  20086.     void *lpData;
  20087.     long flen, mlen;
  20088.     MDxSum mdDataSum;
  20089.     MDxSum md4DataSum;
  20090.  
  20091.     // the 64 is for padding purposes
  20092.     lpData = malloc( READLEN + 64 );
  20093.     
  20094.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  20095.  
  20096.     file = fopen( szFName, "rb" );
  20097.     if( file == NULL )
  20098.     {
  20099.         printf("ERROR: File not found.\n");
  20100.         return;
  20101.     }
  20102.     
  20103.     MDxInit( &mdDataSum );
  20104.     MDxInit( &md4DataSum );
  20105.     
  20106.     fseek( file, 0, SEEK_END );
  20107.     //Get the file length
  20108.     flen = mlen = ftell( file );
  20109.     fseek( file, 0, SEEK_SET );
  20110.     
  20111.     // When it takes a while to process a large file,
  20112.     // remember that for each chunk it has to run 
  20113.     // through the main translation loop 16384 times!
  20114.         
  20115.     printf("Processing %ld byte file: .", flen );
  20116.     
  20117.     while( flen > READLEN )
  20118.     {
  20119.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  20120.         {
  20121.             printf("READ ERROR!\n");
  20122.             return;
  20123.         }
  20124.         MD5Translate( lpData, READLEN, &mdDataSum );
  20125.         MD4Translate( lpData, READLEN, &md4DataSum );
  20126.         flen -= READLEN;
  20127.         printf(".");
  20128.     }
  20129.  
  20130.     if (fread( lpData, 1, flen, file ) != flen)
  20131.     {
  20132.         printf("READ ERROR!\n");
  20133.         return;
  20134.     }
  20135.     // This is why I added the new argument to MDxPad
  20136.     // So we can pass the length of the data AND the
  20137.     // Total length of the message
  20138.     // Also it now returns the # of padding bytes added,
  20139.     // this is for files that are an exact multiple of the chunk
  20140.     // length. (Otherwise the padding isn't Translated)
  20141.     flen += MDxPad( lpData, flen, mlen );
  20142.     MD5Translate( lpData, flen, &mdDataSum );    
  20143.     MD4Translate( lpData, flen, &md4DataSum );
  20144.  
  20145.     // New step necessary because of the 'chunking' method
  20146.     MDxFinalize( &mdDataSum );
  20147.     MDxFinalize( &md4DataSum );
  20148.     
  20149.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  20150.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20151.     fclose(file);
  20152.         
  20153. }
  20154.  
  20155. void DigestString()
  20156. {
  20157.     
  20158.     //For our demo purposes, no strings bigger than 1024 :)
  20159.     unsigned char lpData[1024] = "";
  20160.     long len = 0;
  20161.     MDxSum mdDataSum;
  20162.  
  20163.     printf("Enter the string to digest: ");
  20164.     scanf("%s", &lpData );
  20165.     len = strlen(lpData);
  20166.     
  20167.     // Have to do this before the Padding...well...it's best anyway;)
  20168.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20169.     
  20170.     // For the strings, we're gonna pad and digest the string
  20171.     // in one pass.
  20172.     MDxInit( &mdDataSum );
  20173.     MDxPad( lpData, len, len );
  20174.     
  20175.     MD5Translate( lpData, len, &mdDataSum );
  20176.         // New step necessary because of the 'chunking' method
  20177.         MDxFinalize( &mdDataSum );
  20178.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20179.     
  20180.     MDxInit( &mdDataSum );
  20181.     MD4Translate( lpData, len, &mdDataSum );    
  20182.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20183.  
  20184.     return;
  20185. }
  20186.  
  20187.  
  20188. -------------- Include
  20189.  
  20190. #ifndef __windows_h__
  20191.         typedef unsigned long DWORD;
  20192.         #define STDCALL _stdcall
  20193. #endif
  20194.  
  20195. typedef struct 
  20196. {
  20197.     DWORD dwSum[4];
  20198. }MDxSum;
  20199.  
  20200. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20201. void STDCALL MDxInit( MDxSum * );
  20202. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20203. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20204. const char * STDCALL MDxGetVersion();
  20205. void STDCALL MDxFinalize( MDxSum * );
  20206.  
  20207.  
  20208.  
  20209. #include "mdx.h"
  20210. #include <stdlib.h>
  20211. #include <stdio.h>
  20212. #include <string.h>
  20213.  
  20214. // READLEN % 64 must = 0
  20215. #define READLEN    1048576L // 2^20, 1MB
  20216.  
  20217. void DigestFile( char * );
  20218. void DigestString();
  20219.  
  20220. void main(int argc, char *argv[])
  20221. {
  20222.     printf("%s\n\n", MDxGetVersion());
  20223.  
  20224.     if( argc > 1 )
  20225.         DigestFile( argv[1] );
  20226.     else    
  20227.         DigestString();
  20228.  
  20229. }
  20230.  
  20231. /*
  20232.     I use the 'chunk' method for processing files not because of
  20233.     limitations of my dll, but think what would happen if you
  20234.     tried to load an entire cd image into memory.
  20235. */
  20236. void DigestFile( char *szFName )
  20237. {
  20238.     FILE *file;
  20239.     void *lpData;
  20240.     long flen, mlen;
  20241.     MDxSum mdDataSum;
  20242.     MDxSum md4DataSum;
  20243.  
  20244.     // the 64 is for padding purposes
  20245.     lpData = malloc( READLEN + 64 );
  20246.     
  20247.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  20248.  
  20249.     file = fopen( szFName, "rb" );
  20250.     if( file == NULL )
  20251.     {
  20252.         printf("ERROR: File not found.\n");
  20253.         return;
  20254.     }
  20255.     
  20256.     MDxInit( &mdDataSum );
  20257.     MDxInit( &md4DataSum );
  20258.     
  20259.     fseek( file, 0, SEEK_END );
  20260.     //Get the file length
  20261.     flen = mlen = ftell( file );
  20262.     fseek( file, 0, SEEK_SET );
  20263.     
  20264.     // When it takes a while to process a large file,
  20265.     // remember that for each chunk it has to run 
  20266.     // through the main translation loop 16384 times!
  20267.         
  20268.     printf("Processing %ld byte file: .", flen );
  20269.     
  20270.     while( flen > READLEN )
  20271.     {
  20272.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  20273.         {
  20274.             printf("READ ERROR!\n");
  20275.             return;
  20276.         }
  20277.         MD5Translate( lpData, READLEN, &mdDataSum );
  20278.         MD4Translate( lpData, READLEN, &md4DataSum );
  20279.         flen -= READLEN;
  20280.         printf(".");
  20281.     }
  20282.  
  20283.     if (fread( lpData, 1, flen, file ) != flen)
  20284.     {
  20285.         printf("READ ERROR!\n");
  20286.         return;
  20287.     }
  20288.     // This is why I added the new argument to MDxPad
  20289.     // So we can pass the length of the data AND the
  20290.     // Total length of the message
  20291.     // Also it now returns the # of padding bytes added,
  20292.     // this is for files that are an exact multiple of the chunk
  20293.     // length. (Otherwise the padding isn't Translated)
  20294.     flen += MDxPad( lpData, flen, mlen );
  20295.     MD5Translate( lpData, flen, &mdDataSum );    
  20296.     MD4Translate( lpData, flen, &md4DataSum );
  20297.  
  20298.     // New step necessary because of the 'chunking' method
  20299.     MDxFinalize( &mdDataSum );
  20300.     MDxFinalize( &md4DataSum );
  20301.     
  20302.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  20303.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20304.     fclose(file);
  20305.         
  20306. }
  20307.  
  20308. void DigestString()
  20309. {
  20310.     
  20311.     //For our demo purposes, no strings bigger than 1024 :)
  20312.     unsigned char lpData[1024] = "";
  20313.     long len = 0;
  20314.     MDxSum mdDataSum;
  20315.  
  20316.     printf("Enter the string to digest: ");
  20317.     scanf("%s", &lpData );
  20318.     len = strlen(lpData);
  20319.     
  20320.     // Have to do this before the Padding...well...it's best anyway;)
  20321.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20322.     
  20323.     // For the strings, we're gonna pad and digest the string
  20324.     // in one pass.
  20325.     MDxInit( &mdDataSum );
  20326.     MDxPad( lpData, len, len );
  20327.     
  20328.     MD5Translate( lpData, len, &mdDataSum );
  20329.         // New step necessary because of the 'chunking' method
  20330.         MDxFinalize( &mdDataSum );
  20331.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20332.     
  20333.     MDxInit( &mdDataSum );
  20334.     MD4Translate( lpData, len, &mdDataSum );    
  20335.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20336.  
  20337.     return;
  20338. }
  20339.  
  20340.  
  20341. -------------- Include
  20342.  
  20343. #ifndef __windows_h__
  20344.         typedef unsigned long DWORD;
  20345.         #define STDCALL _stdcall
  20346. #endif
  20347.  
  20348. typedef struct 
  20349. {
  20350.     DWORD dwSum[4];
  20351. }MDxSum;
  20352.  
  20353. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20354. void STDCALL MDxInit( MDxSum * );
  20355. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20356. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20357. const char * STDCALL MDxGetVersion();
  20358. void STDCALL MDxFinalize( MDxSum * );
  20359.  
  20360.  
  20361.  
  20362. #include "mdx.h"
  20363. #include <stdlib.h>
  20364. #include <stdio.h>
  20365. #include <string.h>
  20366.  
  20367. // READLEN % 64 must = 0
  20368. #define READLEN    1048576L // 2^20, 1MB
  20369.  
  20370. void DigestFile( char * );
  20371. void DigestString();
  20372.  
  20373. void main(int argc, char *argv[])
  20374. {
  20375.     printf("%s\n\n", MDxGetVersion());
  20376.  
  20377.     if( argc > 1 )
  20378.         DigestFile( argv[1] );
  20379.     else    
  20380.         DigestString();
  20381.  
  20382. }
  20383.  
  20384. /*
  20385.     I use the 'chunk' method for processing files not because of
  20386.     limitations of my dll, but think what would happen if you
  20387.     tried to load an entire cd image into memory.
  20388. */
  20389. void DigestFile( char *szFName )
  20390. {
  20391.     FILE *file;
  20392.     void *lpData;
  20393.     long flen, mlen;
  20394.     MDxSum mdDataSum;
  20395.     MDxSum md4DataSum;
  20396.  
  20397.     // the 64 is for padding purposes
  20398.     lpData = malloc( READLEN + 64 );
  20399.     
  20400.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  20401.  
  20402.     file = fopen( szFName, "rb" );
  20403.     if( file == NULL )
  20404.     {
  20405.         printf("ERROR: File not found.\n");
  20406.         return;
  20407.     }
  20408.     
  20409.     MDxInit( &mdDataSum );
  20410.     MDxInit( &md4DataSum );
  20411.     
  20412.     fseek( file, 0, SEEK_END );
  20413.     //Get the file length
  20414.     flen = mlen = ftell( file );
  20415.     fseek( file, 0, SEEK_SET );
  20416.     
  20417.     // When it takes a while to process a large file,
  20418.     // remember that for each chunk it has to run 
  20419.     // through the main translation loop 16384 times!
  20420.         
  20421.     printf("Processing %ld byte file: .", flen );
  20422.     
  20423.     while( flen > READLEN )
  20424.     {
  20425.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  20426.         {
  20427.             printf("READ ERROR!\n");
  20428.             return;
  20429.         }
  20430.         MD5Translate( lpData, READLEN, &mdDataSum );
  20431.         MD4Translate( lpData, READLEN, &md4DataSum );
  20432.         flen -= READLEN;
  20433.         printf(".");
  20434.     }
  20435.  
  20436.     if (fread( lpData, 1, flen, file ) != flen)
  20437.     {
  20438.         printf("READ ERROR!\n");
  20439.         return;
  20440.     }
  20441.     // This is why I added the new argument to MDxPad
  20442.     // So we can pass the length of the data AND the
  20443.     // Total length of the message
  20444.     // Also it now returns the # of padding bytes added,
  20445.     // this is for files that are an exact multiple of the chunk
  20446.     // length. (Otherwise the padding isn't Translated)
  20447.     flen += MDxPad( lpData, flen, mlen );
  20448.     MD5Translate( lpData, flen, &mdDataSum );    
  20449.     MD4Translate( lpData, flen, &md4DataSum );
  20450.  
  20451.     // New step necessary because of the 'chunking' method
  20452.     MDxFinalize( &mdDataSum );
  20453.     MDxFinalize( &md4DataSum );
  20454.     
  20455.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  20456.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20457.     fclose(file);
  20458.         
  20459. }
  20460.  
  20461. void DigestString()
  20462. {
  20463.     
  20464.     //For our demo purposes, no strings bigger than 1024 :)
  20465.     unsigned char lpData[1024] = "";
  20466.     long len = 0;
  20467.     MDxSum mdDataSum;
  20468.  
  20469.     printf("Enter the string to digest: ");
  20470.     scanf("%s", &lpData );
  20471.     len = strlen(lpData);
  20472.     
  20473.     // Have to do this before the Padding...well...it's best anyway;)
  20474.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20475.     
  20476.     // For the strings, we're gonna pad and digest the string
  20477.     // in one pass.
  20478.     MDxInit( &mdDataSum );
  20479.     MDxPad( lpData, len, len );
  20480.     
  20481.     MD5Translate( lpData, len, &mdDataSum );
  20482.         // New step necessary because of the 'chunking' method
  20483.         MDxFinalize( &mdDataSum );
  20484.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20485.     
  20486.     MDxInit( &mdDataSum );
  20487.     MD4Translate( lpData, len, &mdDataSum );    
  20488.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20489.  
  20490.     return;
  20491. }
  20492.  
  20493.  
  20494. -------------- Include
  20495.  
  20496. #ifndef __windows_h__
  20497.         typedef unsigned long DWORD;
  20498.         #define STDCALL _stdcall
  20499. #endif
  20500.  
  20501. typedef struct 
  20502. {
  20503.     DWORD dwSum[4];
  20504. }MDxSum;
  20505.  
  20506. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20507. void STDCALL MDxInit( MDxSum * );
  20508. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20509. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20510. const char * STDCALL MDxGetVersion();
  20511. void STDCALL MDxFinalize( MDxSum * );
  20512.  
  20513.  
  20514. #include "mdx.h"
  20515. #include <stdlib.h>
  20516. #include <stdio.h>
  20517. #include <string.h>
  20518.  
  20519. // READLEN % 64 must = 0
  20520. #define READLEN    1048576L // 2^20, 1MB
  20521.  
  20522. void DigestFile( char * );
  20523. void DigestString();
  20524.  
  20525. void main(int argc, char *argv[])
  20526. {
  20527.     printf("%s\n\n", MDxGetVersion());
  20528.  
  20529.     if( argc > 1 )
  20530.         DigestFile( argv[1] );
  20531.     else    
  20532.         DigestString();
  20533.  
  20534. }
  20535.  
  20536. /*
  20537.     I use the 'chunk' method for processing files not because of
  20538.     limitations of my dll, but think what would happen if you
  20539.     tried to load an entire cd image into memory.
  20540. */
  20541. void DigestFile( char *szFName )
  20542. {
  20543.     FILE *file;
  20544.     void *lpData;
  20545.     long flen, mlen;
  20546.     MDxSum mdDataSum;
  20547.     MDxSum md4DataSum;
  20548.  
  20549.     // the 64 is for padding purposes
  20550.     lpData = malloc( READLEN + 64 );
  20551.     
  20552.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  20553.  
  20554.     file = fopen( szFName, "rb" );
  20555.     if( file == NULL )
  20556.     {
  20557.         printf("ERROR: File not found.\n");
  20558.         return;
  20559.     }
  20560.     
  20561.     MDxInit( &mdDataSum );
  20562.     MDxInit( &md4DataSum );
  20563.     
  20564.     fseek( file, 0, SEEK_END );
  20565.     //Get the file length
  20566.     flen = mlen = ftell( file );
  20567.     fseek( file, 0, SEEK_SET );
  20568.     
  20569.     // When it takes a while to process a large file,
  20570.     // remember that for each chunk it has to run 
  20571.     // through the main translation loop 16384 times!
  20572.         
  20573.     printf("Processing %ld byte file: .", flen );
  20574.     
  20575.     while( flen > READLEN )
  20576.     {
  20577.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  20578.         {
  20579.             printf("READ ERROR!\n");
  20580.             return;
  20581.         }
  20582.         MD5Translate( lpData, READLEN, &mdDataSum );
  20583.         MD4Translate( lpData, READLEN, &md4DataSum );
  20584.         flen -= READLEN;
  20585.         printf(".");
  20586.     }
  20587.  
  20588.     if (fread( lpData, 1, flen, file ) != flen)
  20589.     {
  20590.         printf("READ ERROR!\n");
  20591.         return;
  20592.     }
  20593.     // This is why I added the new argument to MDxPad
  20594.     // So we can pass the length of the data AND the
  20595.     // Total length of the message
  20596.     // Also it now returns the # of padding bytes added,
  20597.     // this is for files that are an exact multiple of the chunk
  20598.     // length. (Otherwise the padding isn't Translated)
  20599.     flen += MDxPad( lpData, flen, mlen );
  20600.     MD5Translate( lpData, flen, &mdDataSum );    
  20601.     MD4Translate( lpData, flen, &md4DataSum );
  20602.  
  20603.     // New step necessary because of the 'chunking' method
  20604.     MDxFinalize( &mdDataSum );
  20605.     MDxFinalize( &md4DataSum );
  20606.     
  20607.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  20608.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20609.     fclose(file);
  20610.         
  20611. }
  20612.  
  20613. void DigestString()
  20614. {
  20615.     
  20616.     //For our demo purposes, no strings bigger than 1024 :)
  20617.     unsigned char lpData[1024] = "";
  20618.     long len = 0;
  20619.     MDxSum mdDataSum;
  20620.  
  20621.     printf("Enter the string to digest: ");
  20622.     scanf("%s", &lpData );
  20623.     len = strlen(lpData);
  20624.     
  20625.     // Have to do this before the Padding...well...it's best anyway;)
  20626.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20627.     
  20628.     // For the strings, we're gonna pad and digest the string
  20629.     // in one pass.
  20630.     MDxInit( &mdDataSum );
  20631.     MDxPad( lpData, len, len );
  20632.     
  20633.     MD5Translate( lpData, len, &mdDataSum );
  20634.         // New step necessary because of the 'chunking' method
  20635.         MDxFinalize( &mdDataSum );
  20636.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20637.     
  20638.     MDxInit( &mdDataSum );
  20639.     MD4Translate( lpData, len, &mdDataSum );    
  20640.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20641.  
  20642.     return;
  20643. }
  20644.  
  20645.  
  20646. -------------- Include
  20647.  
  20648. #ifndef __windows_h__
  20649.         typedef unsigned long DWORD;
  20650.         #define STDCALL _stdcall
  20651. #endif
  20652.  
  20653. typedef struct 
  20654. {
  20655.     DWORD dwSum[4];
  20656. }MDxSum;
  20657.  
  20658. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20659. void STDCALL MDxInit( MDxSum * );
  20660. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20661. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20662. const char * STDCALL MDxGetVersion();
  20663. void STDCALL MDxFinalize( MDxSum * );
  20664.  
  20665.  
  20666. #include "mdx.h"
  20667. #include <stdlib.h>
  20668. #include <stdio.h>
  20669. #include <string.h>
  20670.  
  20671. // READLEN % 64 must = 0
  20672. #define READLEN    1048576L // 2^20, 1MB
  20673.  
  20674. void DigestFile( char * );
  20675. void DigestString();
  20676.  
  20677. void main(int argc, char *argv[])
  20678. {
  20679.     printf("%s\n\n", MDxGetVersion());
  20680.  
  20681.     if( argc > 1 )
  20682.         DigestFile( argv[1] );
  20683.     else    
  20684.         DigestString();
  20685.  
  20686. }
  20687.  
  20688. /*
  20689.     I use the 'chunk' method for processing files not because of
  20690.     limitations of my dll, but think what would happen if you
  20691.     tried to load an entire cd image into memory.
  20692. */
  20693. void DigestFile( char *szFName )
  20694. {
  20695.     FILE *file;
  20696.     void *lpData;
  20697.     long flen, mlen;
  20698.     MDxSum mdDataSum;
  20699.     MDxSum md4DataSum;
  20700.  
  20701.     // the 64 is for padding purposes
  20702.     lpData = malloc( READLEN + 64 );
  20703.     
  20704.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  20705.  
  20706.     file = fopen( szFName, "rb" );
  20707.     if( file == NULL )
  20708.     {
  20709.         printf("ERROR: File not found.\n");
  20710.         return;
  20711.     }
  20712.     
  20713.     MDxInit( &mdDataSum );
  20714.     MDxInit( &md4DataSum );
  20715.     
  20716.     fseek( file, 0, SEEK_END );
  20717.     //Get the file length
  20718.     flen = mlen = ftell( file );
  20719.     fseek( file, 0, SEEK_SET );
  20720.     
  20721.     // When it takes a while to process a large file,
  20722.     // remember that for each chunk it has to run 
  20723.     // through the main translation loop 16384 times!
  20724.         
  20725.     printf("Processing %ld byte file: .", flen );
  20726.     
  20727.     while( flen > READLEN )
  20728.     {
  20729.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  20730.         {
  20731.             printf("READ ERROR!\n");
  20732.             return;
  20733.         }
  20734.         MD5Translate( lpData, READLEN, &mdDataSum );
  20735.         MD4Translate( lpData, READLEN, &md4DataSum );
  20736.         flen -= READLEN;
  20737.         printf(".");
  20738.     }
  20739.  
  20740.     if (fread( lpData, 1, flen, file ) != flen)
  20741.     {
  20742.         printf("READ ERROR!\n");
  20743.         return;
  20744.     }
  20745.     // This is why I added the new argument to MDxPad
  20746.     // So we can pass the length of the data AND the
  20747.     // Total length of the message
  20748.     // Also it now returns the # of padding bytes added,
  20749.     // this is for files that are an exact multiple of the chunk
  20750.     // length. (Otherwise the padding isn't Translated)
  20751.     flen += MDxPad( lpData, flen, mlen );
  20752.     MD5Translate( lpData, flen, &mdDataSum );    
  20753.     MD4Translate( lpData, flen, &md4DataSum );
  20754.  
  20755.     // New step necessary because of the 'chunking' method
  20756.     MDxFinalize( &mdDataSum );
  20757.     MDxFinalize( &md4DataSum );
  20758.     
  20759.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  20760.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20761.     fclose(file);
  20762.         
  20763. }
  20764.  
  20765. void DigestString()
  20766. {
  20767.     
  20768.     //For our demo purposes, no strings bigger than 1024 :)
  20769.     unsigned char lpData[1024] = "";
  20770.     long len = 0;
  20771.     MDxSum mdDataSum;
  20772.  
  20773.     printf("Enter the string to digest: ");
  20774.     scanf("%s", &lpData );
  20775.     len = strlen(lpData);
  20776.     
  20777.     // Have to do this before the Padding...well...it's best anyway;)
  20778.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20779.     
  20780.     // For the strings, we're gonna pad and digest the string
  20781.     // in one pass.
  20782.     MDxInit( &mdDataSum );
  20783.     MDxPad( lpData, len, len );
  20784.     
  20785.     MD5Translate( lpData, len, &mdDataSum );
  20786.         // New step necessary because of the 'chunking' method
  20787.         MDxFinalize( &mdDataSum );
  20788.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20789.     
  20790.     MDxInit( &mdDataSum );
  20791.     MD4Translate( lpData, len, &mdDataSum );    
  20792.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20793.  
  20794.     return;
  20795. }
  20796.  
  20797.  
  20798. -------------- Include
  20799.  
  20800. #ifndef __windows_h__
  20801.         typedef unsigned long DWORD;
  20802.         #define STDCALL _stdcall
  20803. #endif
  20804.  
  20805. typedef struct 
  20806. {
  20807.     DWORD dwSum[4];
  20808. }MDxSum;
  20809.  
  20810. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20811. void STDCALL MDxInit( MDxSum * );
  20812. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20813. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20814. const char * STDCALL MDxGetVersion();
  20815. void STDCALL MDxFinalize( MDxSum * );
  20816.  
  20817. #include "mdx.h"
  20818. #include <stdlib.h>
  20819. #include <stdio.h>
  20820. #include <string.h>
  20821.  
  20822. // READLEN % 64 must = 0
  20823. #define READLEN    1048576L // 2^20, 1MB
  20824.  
  20825. void DigestFile( char * );
  20826. void DigestString();
  20827.  
  20828. void main(int argc, char *argv[])
  20829. {
  20830.     printf("%s\n\n", MDxGetVersion());
  20831.  
  20832.     if( argc > 1 )
  20833.         DigestFile( argv[1] );
  20834.     else    
  20835.         DigestString();
  20836.  
  20837. }
  20838.  
  20839. /*
  20840.     I use the 'chunk' method for processing files not because of
  20841.     limitations of my dll, but think what would happen if you
  20842.     tried to load an entire cd image into memory.
  20843. */
  20844. void DigestFile( char *szFName )
  20845. {
  20846.     FILE *file;
  20847.     void *lpData;
  20848.     long flen, mlen;
  20849.     MDxSum mdDataSum;
  20850.     MDxSum md4DataSum;
  20851.  
  20852.     // the 64 is for padding purposes
  20853.     lpData = malloc( READLEN + 64 );
  20854.     
  20855.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  20856.  
  20857.     file = fopen( szFName, "rb" );
  20858.     if( file == NULL )
  20859.     {
  20860.         printf("ERROR: File not found.\n");
  20861.         return;
  20862.     }
  20863.     
  20864.     MDxInit( &mdDataSum );
  20865.     MDxInit( &md4DataSum );
  20866.     
  20867.     fseek( file, 0, SEEK_END );
  20868.     //Get the file length
  20869.     flen = mlen = ftell( file );
  20870.     fseek( file, 0, SEEK_SET );
  20871.     
  20872.     // When it takes a while to process a large file,
  20873.     // remember that for each chunk it has to run 
  20874.     // through the main translation loop 16384 times!
  20875.         
  20876.     printf("Processing %ld byte file: .", flen );
  20877.     
  20878.     while( flen > READLEN )
  20879.     {
  20880.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  20881.         {
  20882.             printf("READ ERROR!\n");
  20883.             return;
  20884.         }
  20885.         MD5Translate( lpData, READLEN, &mdDataSum );
  20886.         MD4Translate( lpData, READLEN, &md4DataSum );
  20887.         flen -= READLEN;
  20888.         printf(".");
  20889.     }
  20890.  
  20891.     if (fread( lpData, 1, flen, file ) != flen)
  20892.     {
  20893.         printf("READ ERROR!\n");
  20894.         return;
  20895.     }
  20896.     // This is why I added the new argument to MDxPad
  20897.     // So we can pass the length of the data AND the
  20898.     // Total length of the message
  20899.     // Also it now returns the # of padding bytes added,
  20900.     // this is for files that are an exact multiple of the chunk
  20901.     // length. (Otherwise the padding isn't Translated)
  20902.     flen += MDxPad( lpData, flen, mlen );
  20903.     MD5Translate( lpData, flen, &mdDataSum );    
  20904.     MD4Translate( lpData, flen, &md4DataSum );
  20905.  
  20906.     // New step necessary because of the 'chunking' method
  20907.     MDxFinalize( &mdDataSum );
  20908.     MDxFinalize( &md4DataSum );
  20909.     
  20910.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  20911.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20912.     fclose(file);
  20913.         
  20914. }
  20915.  
  20916. void DigestString()
  20917. {
  20918.     
  20919.     //For our demo purposes, no strings bigger than 1024 :)
  20920.     unsigned char lpData[1024] = "";
  20921.     long len = 0;
  20922.     MDxSum mdDataSum;
  20923.  
  20924.     printf("Enter the string to digest: ");
  20925.     scanf("%s", &lpData );
  20926.     len = strlen(lpData);
  20927.     
  20928.     // Have to do this before the Padding...well...it's best anyway;)
  20929.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  20930.     
  20931.     // For the strings, we're gonna pad and digest the string
  20932.     // in one pass.
  20933.     MDxInit( &mdDataSum );
  20934.     MDxPad( lpData, len, len );
  20935.     
  20936.     MD5Translate( lpData, len, &mdDataSum );
  20937.         // New step necessary because of the 'chunking' method
  20938.         MDxFinalize( &mdDataSum );
  20939.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20940.     
  20941.     MDxInit( &mdDataSum );
  20942.     MD4Translate( lpData, len, &mdDataSum );    
  20943.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  20944.  
  20945.     return;
  20946. }
  20947.  
  20948.  
  20949. -------------- Include
  20950.  
  20951. #ifndef __windows_h__
  20952.         typedef unsigned long DWORD;
  20953.         #define STDCALL _stdcall
  20954. #endif
  20955.  
  20956. typedef struct 
  20957. {
  20958.     DWORD dwSum[4];
  20959. }MDxSum;
  20960.  
  20961. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  20962. void STDCALL MDxInit( MDxSum * );
  20963. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  20964. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  20965. const char * STDCALL MDxGetVersion();
  20966. void STDCALL MDxFinalize( MDxSum * );
  20967.  
  20968.  
  20969.  
  20970. #include "mdx.h"
  20971. #include <stdlib.h>
  20972. #include <stdio.h>
  20973. #include <string.h>
  20974.  
  20975. // READLEN % 64 must = 0
  20976. #define READLEN    1048576L // 2^20, 1MB
  20977.  
  20978. void DigestFile( char * );
  20979. void DigestString();
  20980.  
  20981. void main(int argc, char *argv[])
  20982. {
  20983.     printf("%s\n\n", MDxGetVersion());
  20984.  
  20985.     if( argc > 1 )
  20986.         DigestFile( argv[1] );
  20987.     else    
  20988.         DigestString();
  20989.  
  20990. }
  20991.  
  20992. /*
  20993.     I use the 'chunk' method for processing files not because of
  20994.     limitations of my dll, but think what would happen if you
  20995.     tried to load an entire cd image into memory.
  20996. */
  20997. void DigestFile( char *szFName )
  20998. {
  20999.     FILE *file;
  21000.     void *lpData;
  21001.     long flen, mlen;
  21002.     MDxSum mdDataSum;
  21003.     MDxSum md4DataSum;
  21004.  
  21005.     // the 64 is for padding purposes
  21006.     lpData = malloc( READLEN + 64 );
  21007.     
  21008.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21009.  
  21010.     file = fopen( szFName, "rb" );
  21011.     if( file == NULL )
  21012.     {
  21013.         printf("ERROR: File not found.\n");
  21014.         return;
  21015.     }
  21016.     
  21017.     MDxInit( &mdDataSum );
  21018.     MDxInit( &md4DataSum );
  21019.     
  21020.     fseek( file, 0, SEEK_END );
  21021.     //Get the file length
  21022.     flen = mlen = ftell( file );
  21023.     fseek( file, 0, SEEK_SET );
  21024.     
  21025.     // When it takes a while to process a large file,
  21026.     // remember that for each chunk it has to run 
  21027.     // through the main translation loop 16384 times!
  21028.         
  21029.     printf("Processing %ld byte file: .", flen );
  21030.     
  21031.     while( flen > READLEN )
  21032.     {
  21033.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21034.         {
  21035.             printf("READ ERROR!\n");
  21036.             return;
  21037.         }
  21038.         MD5Translate( lpData, READLEN, &mdDataSum );
  21039.         MD4Translate( lpData, READLEN, &md4DataSum );
  21040.         flen -= READLEN;
  21041.         printf(".");
  21042.     }
  21043.  
  21044.     if (fread( lpData, 1, flen, file ) != flen)
  21045.     {
  21046.         printf("READ ERROR!\n");
  21047.         return;
  21048.     }
  21049.     // This is why I added the new argument to MDxPad
  21050.     // So we can pass the length of the data AND the
  21051.     // Total length of the message
  21052.     // Also it now returns the # of padding bytes added,
  21053.     // this is for files that are an exact multiple of the chunk
  21054.     // length. (Otherwise the padding isn't Translated)
  21055.     flen += MDxPad( lpData, flen, mlen );
  21056.     MD5Translate( lpData, flen, &mdDataSum );    
  21057.     MD4Translate( lpData, flen, &md4DataSum );
  21058.  
  21059.     // New step necessary because of the 'chunking' method
  21060.     MDxFinalize( &mdDataSum );
  21061.     MDxFinalize( &md4DataSum );
  21062.     
  21063.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21064.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21065.     fclose(file);
  21066.         
  21067. }
  21068.  
  21069. void DigestString()
  21070. {
  21071.     
  21072.     //For our demo purposes, no strings bigger than 1024 :)
  21073.     unsigned char lpData[1024] = "";
  21074.     long len = 0;
  21075.     MDxSum mdDataSum;
  21076.  
  21077.     printf("Enter the string to digest: ");
  21078.     scanf("%s", &lpData );
  21079.     len = strlen(lpData);
  21080.     
  21081.     // Have to do this before the Padding...well...it's best anyway;)
  21082.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  21083.     
  21084.     // For the strings, we're gonna pad and digest the string
  21085.     // in one pass.
  21086.     MDxInit( &mdDataSum );
  21087.     MDxPad( lpData, len, len );
  21088.     
  21089.     MD5Translate( lpData, len, &mdDataSum );
  21090.         // New step necessary because of the 'chunking' method
  21091.         MDxFinalize( &mdDataSum );
  21092.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21093.     
  21094.     MDxInit( &mdDataSum );
  21095.     MD4Translate( lpData, len, &mdDataSum );    
  21096.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21097.  
  21098.     return;
  21099. }
  21100.  
  21101.  
  21102. -------------- Include
  21103.  
  21104. #ifndef __windows_h__
  21105.         typedef unsigned long DWORD;
  21106.         #define STDCALL _stdcall
  21107. #endif
  21108.  
  21109. typedef struct 
  21110. {
  21111.     DWORD dwSum[4];
  21112. }MDxSum;
  21113.  
  21114. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  21115. void STDCALL MDxInit( MDxSum * );
  21116. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  21117. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  21118. const char * STDCALL MDxGetVersion();
  21119. void STDCALL MDxFinalize( MDxSum * );
  21120.  
  21121.  
  21122.  
  21123. #include "mdx.h"
  21124. #include <stdlib.h>
  21125. #include <stdio.h>
  21126. #include <string.h>
  21127.  
  21128. // READLEN % 64 must = 0
  21129. #define READLEN    1048576L // 2^20, 1MB
  21130.  
  21131. void DigestFile( char * );
  21132. void DigestString();
  21133.  
  21134. void main(int argc, char *argv[])
  21135. {
  21136.     printf("%s\n\n", MDxGetVersion());
  21137.  
  21138.     if( argc > 1 )
  21139.         DigestFile( argv[1] );
  21140.     else    
  21141.         DigestString();
  21142.  
  21143. }
  21144.  
  21145. /*
  21146.     I use the 'chunk' method for processing files not because of
  21147.     limitations of my dll, but think what would happen if you
  21148.     tried to load an entire cd image into memory.
  21149. */
  21150. void DigestFile( char *szFName )
  21151. {
  21152.     FILE *file;
  21153.     void *lpData;
  21154.     long flen, mlen;
  21155.     MDxSum mdDataSum;
  21156.     MDxSum md4DataSum;
  21157.  
  21158.     // the 64 is for padding purposes
  21159.     lpData = malloc( READLEN + 64 );
  21160.     
  21161.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21162.  
  21163.     file = fopen( szFName, "rb" );
  21164.     if( file == NULL )
  21165.     {
  21166.         printf("ERROR: File not found.\n");
  21167.         return;
  21168.     }
  21169.     
  21170.     MDxInit( &mdDataSum );
  21171.     MDxInit( &md4DataSum );
  21172.     
  21173.     fseek( file, 0, SEEK_END );
  21174.     //Get the file length
  21175.     flen = mlen = ftell( file );
  21176.     fseek( file, 0, SEEK_SET );
  21177.     
  21178.     // When it takes a while to process a large file,
  21179.     // remember that for each chunk it has to run 
  21180.     // through the main translation loop 16384 times!
  21181.         
  21182.     printf("Processing %ld byte file: .", flen );
  21183.     
  21184.     while( flen > READLEN )
  21185.     {
  21186.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21187.         {
  21188.             printf("READ ERROR!\n");
  21189.             return;
  21190.         }
  21191.         MD5Translate( lpData, READLEN, &mdDataSum );
  21192.         MD4Translate( lpData, READLEN, &md4DataSum );
  21193.         flen -= READLEN;
  21194.         printf(".");
  21195.     }
  21196.  
  21197.     if (fread( lpData, 1, flen, file ) != flen)
  21198.     {
  21199.         printf("READ ERROR!\n");
  21200.         return;
  21201.     }
  21202.     // This is why I added the new argument to MDxPad
  21203.     // So we can pass the length of the data AND the
  21204.     // Total length of the message
  21205.     // Also it now returns the # of padding bytes added,
  21206.     // this is for files that are an exact multiple of the chunk
  21207.     // length. (Otherwise the padding isn't Translated)
  21208.     flen += MDxPad( lpData, flen, mlen );
  21209.     MD5Translate( lpData, flen, &mdDataSum );    
  21210.     MD4Translate( lpData, flen, &md4DataSum );
  21211.  
  21212.     // New step necessary because of the 'chunking' method
  21213.     MDxFinalize( &mdDataSum );
  21214.     MDxFinalize( &md4DataSum );
  21215.     
  21216.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21217.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21218.     fclose(file);
  21219.         
  21220. }
  21221.  
  21222. void DigestString()
  21223. {
  21224.     
  21225.     //For our demo purposes, no strings bigger than 1024 :)
  21226.     unsigned char lpData[1024] = "";
  21227.     long len = 0;
  21228.     MDxSum mdDataSum;
  21229.  
  21230.     printf("Enter the string to digest: ");
  21231.     scanf("%s", &lpData );
  21232.     len = strlen(lpData);
  21233.     
  21234.     // Have to do this before the Padding...well...it's best anyway;)
  21235.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  21236.     
  21237.     // For the strings, we're gonna pad and digest the string
  21238.     // in one pass.
  21239.     MDxInit( &mdDataSum );
  21240.     MDxPad( lpData, len, len );
  21241.     
  21242.     MD5Translate( lpData, len, &mdDataSum );
  21243.         // New step necessary because of the 'chunking' method
  21244.         MDxFinalize( &mdDataSum );
  21245.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21246.     
  21247.     MDxInit( &mdDataSum );
  21248.     MD4Translate( lpData, len, &mdDataSum );    
  21249.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21250.  
  21251.     return;
  21252. }
  21253.  
  21254.  
  21255. -------------- Include
  21256.  
  21257. #ifndef __windows_h__
  21258.         typedef unsigned long DWORD;
  21259.         #define STDCALL _stdcall
  21260. #endif
  21261.  
  21262. typedef struct 
  21263. {
  21264.     DWORD dwSum[4];
  21265. }MDxSum;
  21266.  
  21267. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  21268. void STDCALL MDxInit( MDxSum * );
  21269. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  21270. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  21271. const char * STDCALL MDxGetVersion();
  21272. void STDCALL MDxFinalize( MDxSum * );
  21273.  
  21274.  
  21275.  
  21276. #include "mdx.h"
  21277. #include <stdlib.h>
  21278. #include <stdio.h>
  21279. #include <string.h>
  21280.  
  21281. // READLEN % 64 must = 0
  21282. #define READLEN    1048576L // 2^20, 1MB
  21283.  
  21284. void DigestFile( char * );
  21285. void DigestString();
  21286.  
  21287. void main(int argc, char *argv[])
  21288. {
  21289.     printf("%s\n\n", MDxGetVersion());
  21290.  
  21291.     if( argc > 1 )
  21292.         DigestFile( argv[1] );
  21293.     else    
  21294.         DigestString();
  21295.  
  21296. }
  21297.  
  21298. /*
  21299.     I use the 'chunk' method for processing files not because of
  21300.     limitations of my dll, but think what would happen if you
  21301.     tried to load an entire cd image into memory.
  21302. */
  21303. void DigestFile( char *szFName )
  21304. {
  21305.     FILE *file;
  21306.     void *lpData;
  21307.     long flen, mlen;
  21308.     MDxSum mdDataSum;
  21309.     MDxSum md4DataSum;
  21310.  
  21311.     // the 64 is for padding purposes
  21312.     lpData = malloc( READLEN + 64 );
  21313.     
  21314.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21315.  
  21316.     file = fopen( szFName, "rb" );
  21317.     if( file == NULL )
  21318.     {
  21319.         printf("ERROR: File not found.\n");
  21320.         return;
  21321.     }
  21322.     
  21323.     MDxInit( &mdDataSum );
  21324.     MDxInit( &md4DataSum );
  21325.     
  21326.     fseek( file, 0, SEEK_END );
  21327.     //Get the file length
  21328.     flen = mlen = ftell( file );
  21329.     fseek( file, 0, SEEK_SET );
  21330.     
  21331.     // When it takes a while to process a large file,
  21332.     // remember that for each chunk it has to run 
  21333.     // through the main translation loop 16384 times!
  21334.         
  21335.     printf("Processing %ld byte file: .", flen );
  21336.     
  21337.     while( flen > READLEN )
  21338.     {
  21339.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21340.         {
  21341.             printf("READ ERROR!\n");
  21342.             return;
  21343.         }
  21344.         MD5Translate( lpData, READLEN, &mdDataSum );
  21345.         MD4Translate( lpData, READLEN, &md4DataSum );
  21346.         flen -= READLEN;
  21347.         printf(".");
  21348.     }
  21349.  
  21350.     if (fread( lpData, 1, flen, file ) != flen)
  21351.     {
  21352.         printf("READ ERROR!\n");
  21353.         return;
  21354.     }
  21355.     // This is why I added the new argument to MDxPad
  21356.     // So we can pass the length of the data AND the
  21357.     // Total length of the message
  21358.     // Also it now returns the # of padding bytes added,
  21359.     // this is for files that are an exact multiple of the chunk
  21360.     // length. (Otherwise the padding isn't Translated)
  21361.     flen += MDxPad( lpData, flen, mlen );
  21362.     MD5Translate( lpData, flen, &mdDataSum );    
  21363.     MD4Translate( lpData, flen, &md4DataSum );
  21364.  
  21365.     // New step necessary because of the 'chunking' method
  21366.     MDxFinalize( &mdDataSum );
  21367.     MDxFinalize( &md4DataSum );
  21368.     
  21369.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21370.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21371.     fclose(file);
  21372.         
  21373. }
  21374.  
  21375. void DigestString()
  21376. {
  21377.     
  21378.     //For our demo purposes, no strings bigger than 1024 :)
  21379.     unsigned char lpData[1024] = "";
  21380.     long len = 0;
  21381.     MDxSum mdDataSum;
  21382.  
  21383.     printf("Enter the string to digest: ");
  21384.     scanf("%s", &lpData );
  21385.     len = strlen(lpData);
  21386.     
  21387.     // Have to do this before the Padding...well...it's best anyway;)
  21388.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  21389.     
  21390.     // For the strings, we're gonna pad and digest the string
  21391.     // in one pass.
  21392.     MDxInit( &mdDataSum );
  21393.     MDxPad( lpData, len, len );
  21394.     
  21395.     MD5Translate( lpData, len, &mdDataSum );
  21396.         // New step necessary because of the 'chunking' method
  21397.         MDxFinalize( &mdDataSum );
  21398.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21399.     
  21400.     MDxInit( &mdDataSum );
  21401.     MD4Translate( lpData, len, &mdDataSum );    
  21402.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21403.  
  21404.     return;
  21405. }
  21406.  
  21407.  
  21408. -------------- Include
  21409.  
  21410. #ifndef __windows_h__
  21411.         typedef unsigned long DWORD;
  21412.         #define STDCALL _stdcall
  21413. #endif
  21414.  
  21415. typedef struct 
  21416. {
  21417.     DWORD dwSum[4];
  21418. }MDxSum;
  21419.  
  21420. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  21421. void STDCALL MDxInit( MDxSum * );
  21422. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  21423. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  21424. const char * STDCALL MDxGetVersion();
  21425. void STDCALL MDxFinalize( MDxSum * );
  21426.  
  21427.  
  21428.  
  21429. #include "mdx.h"
  21430. #include <stdlib.h>
  21431. #include <stdio.h>
  21432. #include <string.h>
  21433.  
  21434. // READLEN % 64 must = 0
  21435. #define READLEN    1048576L // 2^20, 1MB
  21436.  
  21437. void DigestFile( char * );
  21438. void DigestString();
  21439.  
  21440. void main(int argc, char *argv[])
  21441. {
  21442.     printf("%s\n\n", MDxGetVersion());
  21443.  
  21444.     if( argc > 1 )
  21445.         DigestFile( argv[1] );
  21446.     else    
  21447.         DigestString();
  21448.  
  21449. }
  21450.  
  21451. /*
  21452.     I use the 'chunk' method for processing files not because of
  21453.     limitations of my dll, but think what would happen if you
  21454.     tried to load an entire cd image into memory.
  21455. */
  21456. void DigestFile( char *szFName )
  21457. {
  21458.     FILE *file;
  21459.     void *lpData;
  21460.     long flen, mlen;
  21461.     MDxSum mdDataSum;
  21462.     MDxSum md4DataSum;
  21463.  
  21464.     // the 64 is for padding purposes
  21465.     lpData = malloc( READLEN + 64 );
  21466.     
  21467.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21468.  
  21469.     file = fopen( szFName, "rb" );
  21470.     if( file == NULL )
  21471.     {
  21472.         printf("ERROR: File not found.\n");
  21473.         return;
  21474.     }
  21475.     
  21476.     MDxInit( &mdDataSum );
  21477.     MDxInit( &md4DataSum );
  21478.     
  21479.     fseek( file, 0, SEEK_END );
  21480.     //Get the file length
  21481.     flen = mlen = ftell( file );
  21482.     fseek( file, 0, SEEK_SET );
  21483.     
  21484.     // When it takes a while to process a large file,
  21485.     // remember that for each chunk it has to run 
  21486.     // through the main translation loop 16384 times!
  21487.         
  21488.     printf("Processing %ld byte file: .", flen );
  21489.     
  21490.     while( flen > READLEN )
  21491.     {
  21492.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21493.         {
  21494.             printf("READ ERROR!\n");
  21495.             return;
  21496.         }
  21497.         MD5Translate( lpData, READLEN, &mdDataSum );
  21498.         MD4Translate( lpData, READLEN, &md4DataSum );
  21499.         flen -= READLEN;
  21500.         printf(".");
  21501.     }
  21502.  
  21503.     if (fread( lpData, 1, flen, file ) != flen)
  21504.     {
  21505.         printf("READ ERROR!\n");
  21506.         return;
  21507.     }
  21508.     // This is why I added the new argument to MDxPad
  21509.     // So we can pass the length of the data AND the
  21510.     // Total length of the message
  21511.     // Also it now returns the # of padding bytes added,
  21512.     // this is for files that are an exact multiple of the chunk
  21513.     // length. (Otherwise the padding isn't Translated)
  21514.     flen += MDxPad( lpData, flen, mlen );
  21515.     MD5Translate( lpData, flen, &mdDataSum );    
  21516.     MD4Translate( lpData, flen, &md4DataSum );
  21517.  
  21518.     // New step necessary because of the 'chunking' method
  21519.     MDxFinalize( &mdDataSum );
  21520.     MDxFinalize( &md4DataSum );
  21521.     
  21522.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21523.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21524.     fclose(file);
  21525.         
  21526. }
  21527.  
  21528. void DigestString()
  21529. {
  21530.     
  21531.     //For our demo purposes, no strings bigger than 1024 :)
  21532.     unsigned char lpData[1024] = "";
  21533.     long len = 0;
  21534.     MDxSum mdDataSum;
  21535.  
  21536.     printf("Enter the string to digest: ");
  21537.     scanf("%s", &lpData );
  21538.     len = strlen(lpData);
  21539.     
  21540.     // Have to do this before the Padding...well...it's best anyway;)
  21541.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  21542.     
  21543.     // For the strings, we're gonna pad and digest the string
  21544.     // in one pass.
  21545.     MDxInit( &mdDataSum );
  21546.     MDxPad( lpData, len, len );
  21547.     
  21548.     MD5Translate( lpData, len, &mdDataSum );
  21549.         // New step necessary because of the 'chunking' method
  21550.         MDxFinalize( &mdDataSum );
  21551.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21552.     
  21553.     MDxInit( &mdDataSum );
  21554.     MD4Translate( lpData, len, &mdDataSum );    
  21555.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21556.  
  21557.     return;
  21558. }
  21559.  
  21560.  
  21561. -------------- Include
  21562.  
  21563. #ifndef __windows_h__
  21564.         typedef unsigned long DWORD;
  21565.         #define STDCALL _stdcall
  21566. #endif
  21567.  
  21568. typedef struct 
  21569. {
  21570.     DWORD dwSum[4];
  21571. }MDxSum;
  21572.  
  21573. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  21574. void STDCALL MDxInit( MDxSum * );
  21575. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  21576. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  21577. const char * STDCALL MDxGetVersion();
  21578. void STDCALL MDxFinalize( MDxSum * );
  21579.  
  21580.  
  21581.  
  21582.  
  21583. #include "mdx.h"
  21584. #include <stdlib.h>
  21585. #include <stdio.h>
  21586. #include <string.h>
  21587.  
  21588. // READLEN % 64 must = 0
  21589. #define READLEN    1048576L // 2^20, 1MB
  21590.  
  21591. void DigestFile( char * );
  21592. void DigestString();
  21593.  
  21594. void main(int argc, char *argv[])
  21595. {
  21596.     printf("%s\n\n", MDxGetVersion());
  21597.  
  21598.     if( argc > 1 )
  21599.         DigestFile( argv[1] );
  21600.     else    
  21601.         DigestString();
  21602.  
  21603. }
  21604.  
  21605. /*
  21606.     I use the 'chunk' method for processing files not because of
  21607.     limitations of my dll, but think what would happen if you
  21608.     tried to load an entire cd image into memory.
  21609. */
  21610. void DigestFile( char *szFName )
  21611. {
  21612.     FILE *file;
  21613.     void *lpData;
  21614.     long flen, mlen;
  21615.     MDxSum mdDataSum;
  21616.     MDxSum md4DataSum;
  21617.  
  21618.     // the 64 is for padding purposes
  21619.     lpData = malloc( READLEN + 64 );
  21620.     
  21621.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21622.  
  21623.     file = fopen( szFName, "rb" );
  21624.     if( file == NULL )
  21625.     {
  21626.         printf("ERROR: File not found.\n");
  21627.         return;
  21628.     }
  21629.     
  21630.     MDxInit( &mdDataSum );
  21631.     MDxInit( &md4DataSum );
  21632.     
  21633.     fseek( file, 0, SEEK_END );
  21634.     //Get the file length
  21635.     flen = mlen = ftell( file );
  21636.     fseek( file, 0, SEEK_SET );
  21637.     
  21638.     // When it takes a while to process a large file,
  21639.     // remember that for each chunk it has to run 
  21640.     // through the main translation loop 16384 times!
  21641.         
  21642.     printf("Processing %ld byte file: .", flen );
  21643.     
  21644.     while( flen > READLEN )
  21645.     {
  21646.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21647.         {
  21648.             printf("READ ERROR!\n");
  21649.             return;
  21650.         }
  21651.         MD5Translate( lpData, READLEN, &mdDataSum );
  21652.         MD4Translate( lpData, READLEN, &md4DataSum );
  21653.         flen -= READLEN;
  21654.         printf(".");
  21655.     }
  21656.  
  21657.     if (fread( lpData, 1, flen, file ) != flen)
  21658.     {
  21659.         printf("READ ERROR!\n");
  21660.         return;
  21661.     }
  21662.     // This is why I added the new argument to MDxPad
  21663.     // So we can pass the length of the data AND the
  21664.     // Total length of the message
  21665.     // Also it now returns the # of padding bytes added,
  21666.     // this is for files that are an exact multiple of the chunk
  21667.     // length. (Otherwise the padding isn't Translated)
  21668.     flen += MDxPad( lpData, flen, mlen );
  21669.     MD5Translate( lpData, flen, &mdDataSum );    
  21670.     MD4Translate( lpData, flen, &md4DataSum );
  21671.  
  21672.     // New step necessary because of the 'chunking' method
  21673.     MDxFinalize( &mdDataSum );
  21674.     MDxFinalize( &md4DataSum );
  21675.     
  21676.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21677.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21678.     fclose(file);
  21679.         
  21680. }
  21681.  
  21682. void DigestString()
  21683. {
  21684.     
  21685.     //For our demo purposes, no strings bigger than 1024 :)
  21686.     unsigned char lpData[1024] = "";
  21687.     long len = 0;
  21688.     MDxSum mdDataSum;
  21689.  
  21690.     printf("Enter the string to digest: ");
  21691.     scanf("%s", &lpData );
  21692.     len = strlen(lpData);
  21693.     
  21694.     // Have to do this before the Padding...well...it's best anyway;)
  21695.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  21696.     
  21697.     // For the strings, we're gonna pad and digest the string
  21698.     // in one pass.
  21699.     MDxInit( &mdDataSum );
  21700.     MDxPad( lpData, len, len );
  21701.     
  21702.     MD5Translate( lpData, len, &mdDataSum );
  21703.         // New step necessary because of the 'chunking' method
  21704.         MDxFinalize( &mdDataSum );
  21705.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21706.     
  21707.     MDxInit( &mdDataSum );
  21708.     MD4Translate( lpData, len, &mdDataSum );    
  21709.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21710.  
  21711.     return;
  21712. }
  21713.  
  21714.  
  21715. -------------- Include
  21716.  
  21717. #ifndef __windows_h__
  21718.         typedef unsigned long DWORD;
  21719.         #define STDCALL _stdcall
  21720. #endif
  21721.  
  21722. typedef struct 
  21723. {
  21724.     DWORD dwSum[4];
  21725. }MDxSum;
  21726.  
  21727. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  21728. void STDCALL MDxInit( MDxSum * );
  21729. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  21730. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  21731. const char * STDCALL MDxGetVersion();
  21732. void STDCALL MDxFinalize( MDxSum * );
  21733.  
  21734.  
  21735.  
  21736.  
  21737. #include "mdx.h"
  21738. #include <stdlib.h>
  21739. #include <stdio.h>
  21740. #include <string.h>
  21741.  
  21742. // READLEN % 64 must = 0
  21743. #define READLEN    1048576L // 2^20, 1MB
  21744.  
  21745. void DigestFile( char * );
  21746. void DigestString();
  21747.  
  21748. void main(int argc, char *argv[])
  21749. {
  21750.     printf("%s\n\n", MDxGetVersion());
  21751.  
  21752.     if( argc > 1 )
  21753.         DigestFile( argv[1] );
  21754.     else    
  21755.         DigestString();
  21756.  
  21757. }
  21758.  
  21759. /*
  21760.     I use the 'chunk' method for processing files not because of
  21761.     limitations of my dll, but think what would happen if you
  21762.     tried to load an entire cd image into memory.
  21763. */
  21764. void DigestFile( char *szFName )
  21765. {
  21766.     FILE *file;
  21767.     void *lpData;
  21768.     long flen, mlen;
  21769.     MDxSum mdDataSum;
  21770.     MDxSum md4DataSum;
  21771.  
  21772.     // the 64 is for padding purposes
  21773.     lpData = malloc( READLEN + 64 );
  21774.     
  21775.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21776.  
  21777.     file = fopen( szFName, "rb" );
  21778.     if( file == NULL )
  21779.     {
  21780.         printf("ERROR: File not found.\n");
  21781.         return;
  21782.     }
  21783.     
  21784.     MDxInit( &mdDataSum );
  21785.     MDxInit( &md4DataSum );
  21786.     
  21787.     fseek( file, 0, SEEK_END );
  21788.     //Get the file length
  21789.     flen = mlen = ftell( file );
  21790.     fseek( file, 0, SEEK_SET );
  21791.     
  21792.     // When it takes a while to process a large file,
  21793.     // remember that for each chunk it has to run 
  21794.     // through the main translation loop 16384 times!
  21795.         
  21796.     printf("Processing %ld byte file: .", flen );
  21797.     
  21798.     while( flen > READLEN )
  21799.     {
  21800.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21801.         {
  21802.             printf("READ ERROR!\n");
  21803.             return;
  21804.         }
  21805.         MD5Translate( lpData, READLEN, &mdDataSum );
  21806.         MD4Translate( lpData, READLEN, &md4DataSum );
  21807.         flen -= READLEN;
  21808.         printf(".");
  21809.     }
  21810.  
  21811.     if (fread( lpData, 1, flen, file ) != flen)
  21812.     {
  21813.         printf("READ ERROR!\n");
  21814.         return;
  21815.     }
  21816.     // This is why I added the new argument to MDxPad
  21817.     // So we can pass the length of the data AND the
  21818.     // Total length of the message
  21819.     // Also it now returns the # of padding bytes added,
  21820.     // this is for files that are an exact multiple of the chunk
  21821.     // length. (Otherwise the padding isn't Translated)
  21822.     flen += MDxPad( lpData, flen, mlen );
  21823.     MD5Translate( lpData, flen, &mdDataSum );    
  21824.     MD4Translate( lpData, flen, &md4DataSum );
  21825.  
  21826.     // New step necessary because of the 'chunking' method
  21827.     MDxFinalize( &mdDataSum );
  21828.     MDxFinalize( &md4DataSum );
  21829.     
  21830.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21831.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21832.     fclose(file);
  21833.         
  21834. }
  21835.  
  21836. void DigestString()
  21837. {
  21838.     
  21839.     //For our demo purposes, no strings bigger than 1024 :)
  21840.     unsigned char lpData[1024] = "";
  21841.     long len = 0;
  21842.     MDxSum mdDataSum;
  21843.  
  21844.     printf("Enter the string to digest: ");
  21845.     scanf("%s", &lpData );
  21846.     len = strlen(lpData);
  21847.     
  21848.     // Have to do this before the Padding...well...it's best anyway;)
  21849.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  21850.     
  21851.     // For the strings, we're gonna pad and digest the string
  21852.     // in one pass.
  21853.     MDxInit( &mdDataSum );
  21854.     MDxPad( lpData, len, len );
  21855.     
  21856.     MD5Translate( lpData, len, &mdDataSum );
  21857.         // New step necessary because of the 'chunking' method
  21858.         MDxFinalize( &mdDataSum );
  21859.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21860.     
  21861.     MDxInit( &mdDataSum );
  21862.     MD4Translate( lpData, len, &mdDataSum );    
  21863.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21864.  
  21865.     return;
  21866. }
  21867.  
  21868.  
  21869. -------------- Include
  21870.  
  21871. #ifndef __windows_h__
  21872.         typedef unsigned long DWORD;
  21873.         #define STDCALL _stdcall
  21874. #endif
  21875.  
  21876. typedef struct 
  21877. {
  21878.     DWORD dwSum[4];
  21879. }MDxSum;
  21880.  
  21881. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  21882. void STDCALL MDxInit( MDxSum * );
  21883. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  21884. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  21885. const char * STDCALL MDxGetVersion();
  21886. void STDCALL MDxFinalize( MDxSum * );
  21887.  
  21888.  
  21889.  
  21890.  
  21891. #include "mdx.h"
  21892. #include <stdlib.h>
  21893. #include <stdio.h>
  21894. #include <string.h>
  21895.  
  21896. // READLEN % 64 must = 0
  21897. #define READLEN    1048576L // 2^20, 1MB
  21898.  
  21899. void DigestFile( char * );
  21900. void DigestString();
  21901.  
  21902. void main(int argc, char *argv[])
  21903. {
  21904.     printf("%s\n\n", MDxGetVersion());
  21905.  
  21906.     if( argc > 1 )
  21907.         DigestFile( argv[1] );
  21908.     else    
  21909.         DigestString();
  21910.  
  21911. }
  21912.  
  21913. /*
  21914.     I use the 'chunk' method for processing files not because of
  21915.     limitations of my dll, but think what would happen if you
  21916.     tried to load an entire cd image into memory.
  21917. */
  21918. void DigestFile( char *szFName )
  21919. {
  21920.     FILE *file;
  21921.     void *lpData;
  21922.     long flen, mlen;
  21923.     MDxSum mdDataSum;
  21924.     MDxSum md4DataSum;
  21925.  
  21926.     // the 64 is for padding purposes
  21927.     lpData = malloc( READLEN + 64 );
  21928.     
  21929.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  21930.  
  21931.     file = fopen( szFName, "rb" );
  21932.     if( file == NULL )
  21933.     {
  21934.         printf("ERROR: File not found.\n");
  21935.         return;
  21936.     }
  21937.     
  21938.     MDxInit( &mdDataSum );
  21939.     MDxInit( &md4DataSum );
  21940.     
  21941.     fseek( file, 0, SEEK_END );
  21942.     //Get the file length
  21943.     flen = mlen = ftell( file );
  21944.     fseek( file, 0, SEEK_SET );
  21945.     
  21946.     // When it takes a while to process a large file,
  21947.     // remember that for each chunk it has to run 
  21948.     // through the main translation loop 16384 times!
  21949.         
  21950.     printf("Processing %ld byte file: .", flen );
  21951.     
  21952.     while( flen > READLEN )
  21953.     {
  21954.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  21955.         {
  21956.             printf("READ ERROR!\n");
  21957.             return;
  21958.         }
  21959.         MD5Translate( lpData, READLEN, &mdDataSum );
  21960.         MD4Translate( lpData, READLEN, &md4DataSum );
  21961.         flen -= READLEN;
  21962.         printf(".");
  21963.     }
  21964.  
  21965.     if (fread( lpData, 1, flen, file ) != flen)
  21966.     {
  21967.         printf("READ ERROR!\n");
  21968.         return;
  21969.     }
  21970.     // This is why I added the new argument to MDxPad
  21971.     // So we can pass the length of the data AND the
  21972.     // Total length of the message
  21973.     // Also it now returns the # of padding bytes added,
  21974.     // this is for files that are an exact multiple of the chunk
  21975.     // length. (Otherwise the padding isn't Translated)
  21976.     flen += MDxPad( lpData, flen, mlen );
  21977.     MD5Translate( lpData, flen, &mdDataSum );    
  21978.     MD4Translate( lpData, flen, &md4DataSum );
  21979.  
  21980.     // New step necessary because of the 'chunking' method
  21981.     MDxFinalize( &mdDataSum );
  21982.     MDxFinalize( &md4DataSum );
  21983.     
  21984.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  21985.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  21986.     fclose(file);
  21987.         
  21988. }
  21989.  
  21990. void DigestString()
  21991. {
  21992.     
  21993.     //For our demo purposes, no strings bigger than 1024 :)
  21994.     unsigned char lpData[1024] = "";
  21995.     long len = 0;
  21996.     MDxSum mdDataSum;
  21997.  
  21998.     printf("Enter the string to digest: ");
  21999.     scanf("%s", &lpData );
  22000.     len = strlen(lpData);
  22001.     
  22002.     // Have to do this before the Padding...well...it's best anyway;)
  22003.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22004.     
  22005.     // For the strings, we're gonna pad and digest the string
  22006.     // in one pass.
  22007.     MDxInit( &mdDataSum );
  22008.     MDxPad( lpData, len, len );
  22009.     
  22010.     MD5Translate( lpData, len, &mdDataSum );
  22011.         // New step necessary because of the 'chunking' method
  22012.         MDxFinalize( &mdDataSum );
  22013.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22014.     
  22015.     MDxInit( &mdDataSum );
  22016.     MD4Translate( lpData, len, &mdDataSum );    
  22017.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22018.  
  22019.     return;
  22020. }
  22021.  
  22022.  
  22023. -------------- Include
  22024.  
  22025. #ifndef __windows_h__
  22026.         typedef unsigned long DWORD;
  22027.         #define STDCALL _stdcall
  22028. #endif
  22029.  
  22030. typedef struct 
  22031. {
  22032.     DWORD dwSum[4];
  22033. }MDxSum;
  22034.  
  22035. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22036. void STDCALL MDxInit( MDxSum * );
  22037. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22038. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22039. const char * STDCALL MDxGetVersion();
  22040. void STDCALL MDxFinalize( MDxSum * );
  22041.  
  22042.  
  22043.  
  22044. #include "mdx.h"
  22045. #include <stdlib.h>
  22046. #include <stdio.h>
  22047. #include <string.h>
  22048.  
  22049. // READLEN % 64 must = 0
  22050. #define READLEN    1048576L // 2^20, 1MB
  22051.  
  22052. void DigestFile( char * );
  22053. void DigestString();
  22054.  
  22055. void main(int argc, char *argv[])
  22056. {
  22057.     printf("%s\n\n", MDxGetVersion());
  22058.  
  22059.     if( argc > 1 )
  22060.         DigestFile( argv[1] );
  22061.     else    
  22062.         DigestString();
  22063.  
  22064. }
  22065.  
  22066. /*
  22067.     I use the 'chunk' method for processing files not because of
  22068.     limitations of my dll, but think what would happen if you
  22069.     tried to load an entire cd image into memory.
  22070. */
  22071. void DigestFile( char *szFName )
  22072. {
  22073.     FILE *file;
  22074.     void *lpData;
  22075.     long flen, mlen;
  22076.     MDxSum mdDataSum;
  22077.     MDxSum md4DataSum;
  22078.  
  22079.     // the 64 is for padding purposes
  22080.     lpData = malloc( READLEN + 64 );
  22081.     
  22082.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  22083.  
  22084.     file = fopen( szFName, "rb" );
  22085.     if( file == NULL )
  22086.     {
  22087.         printf("ERROR: File not found.\n");
  22088.         return;
  22089.     }
  22090.     
  22091.     MDxInit( &mdDataSum );
  22092.     MDxInit( &md4DataSum );
  22093.     
  22094.     fseek( file, 0, SEEK_END );
  22095.     //Get the file length
  22096.     flen = mlen = ftell( file );
  22097.     fseek( file, 0, SEEK_SET );
  22098.     
  22099.     // When it takes a while to process a large file,
  22100.     // remember that for each chunk it has to run 
  22101.     // through the main translation loop 16384 times!
  22102.         
  22103.     printf("Processing %ld byte file: .", flen );
  22104.     
  22105.     while( flen > READLEN )
  22106.     {
  22107.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  22108.         {
  22109.             printf("READ ERROR!\n");
  22110.             return;
  22111.         }
  22112.         MD5Translate( lpData, READLEN, &mdDataSum );
  22113.         MD4Translate( lpData, READLEN, &md4DataSum );
  22114.         flen -= READLEN;
  22115.         printf(".");
  22116.     }
  22117.  
  22118.     if (fread( lpData, 1, flen, file ) != flen)
  22119.     {
  22120.         printf("READ ERROR!\n");
  22121.         return;
  22122.     }
  22123.     // This is why I added the new argument to MDxPad
  22124.     // So we can pass the length of the data AND the
  22125.     // Total length of the message
  22126.     // Also it now returns the # of padding bytes added,
  22127.     // this is for files that are an exact multiple of the chunk
  22128.     // length. (Otherwise the padding isn't Translated)
  22129.     flen += MDxPad( lpData, flen, mlen );
  22130.     MD5Translate( lpData, flen, &mdDataSum );    
  22131.     MD4Translate( lpData, flen, &md4DataSum );
  22132.  
  22133.     // New step necessary because of the 'chunking' method
  22134.     MDxFinalize( &mdDataSum );
  22135.     MDxFinalize( &md4DataSum );
  22136.     
  22137.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  22138.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22139.     fclose(file);
  22140.         
  22141. }
  22142.  
  22143. void DigestString()
  22144. {
  22145.     
  22146.     //For our demo purposes, no strings bigger than 1024 :)
  22147.     unsigned char lpData[1024] = "";
  22148.     long len = 0;
  22149.     MDxSum mdDataSum;
  22150.  
  22151.     printf("Enter the string to digest: ");
  22152.     scanf("%s", &lpData );
  22153.     len = strlen(lpData);
  22154.     
  22155.     // Have to do this before the Padding...well...it's best anyway;)
  22156.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22157.     
  22158.     // For the strings, we're gonna pad and digest the string
  22159.     // in one pass.
  22160.     MDxInit( &mdDataSum );
  22161.     MDxPad( lpData, len, len );
  22162.     
  22163.     MD5Translate( lpData, len, &mdDataSum );
  22164.         // New step necessary because of the 'chunking' method
  22165.         MDxFinalize( &mdDataSum );
  22166.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22167.     
  22168.     MDxInit( &mdDataSum );
  22169.     MD4Translate( lpData, len, &mdDataSum );    
  22170.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22171.  
  22172.     return;
  22173. }
  22174.  
  22175.  
  22176. -------------- Include
  22177.  
  22178. #ifndef __windows_h__
  22179.         typedef unsigned long DWORD;
  22180.         #define STDCALL _stdcall
  22181. #endif
  22182.  
  22183. typedef struct 
  22184. {
  22185.     DWORD dwSum[4];
  22186. }MDxSum;
  22187.  
  22188. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22189. void STDCALL MDxInit( MDxSum * );
  22190. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22191. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22192. const char * STDCALL MDxGetVersion();
  22193. void STDCALL MDxFinalize( MDxSum * );
  22194.  
  22195.  
  22196.  
  22197. #include "mdx.h"
  22198. #include <stdlib.h>
  22199. #include <stdio.h>
  22200. #include <string.h>
  22201.  
  22202. // READLEN % 64 must = 0
  22203. #define READLEN    1048576L // 2^20, 1MB
  22204.  
  22205. void DigestFile( char * );
  22206. void DigestString();
  22207.  
  22208. void main(int argc, char *argv[])
  22209. {
  22210.     printf("%s\n\n", MDxGetVersion());
  22211.  
  22212.     if( argc > 1 )
  22213.         DigestFile( argv[1] );
  22214.     else    
  22215.         DigestString();
  22216.  
  22217. }
  22218.  
  22219. /*
  22220.     I use the 'chunk' method for processing files not because of
  22221.     limitations of my dll, but think what would happen if you
  22222.     tried to load an entire cd image into memory.
  22223. */
  22224. void DigestFile( char *szFName )
  22225. {
  22226.     FILE *file;
  22227.     void *lpData;
  22228.     long flen, mlen;
  22229.     MDxSum mdDataSum;
  22230.     MDxSum md4DataSum;
  22231.  
  22232.     // the 64 is for padding purposes
  22233.     lpData = malloc( READLEN + 64 );
  22234.     
  22235.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  22236.  
  22237.     file = fopen( szFName, "rb" );
  22238.     if( file == NULL )
  22239.     {
  22240.         printf("ERROR: File not found.\n");
  22241.         return;
  22242.     }
  22243.     
  22244.     MDxInit( &mdDataSum );
  22245.     MDxInit( &md4DataSum );
  22246.     
  22247.     fseek( file, 0, SEEK_END );
  22248.     //Get the file length
  22249.     flen = mlen = ftell( file );
  22250.     fseek( file, 0, SEEK_SET );
  22251.     
  22252.     // When it takes a while to process a large file,
  22253.     // remember that for each chunk it has to run 
  22254.     // through the main translation loop 16384 times!
  22255.         
  22256.     printf("Processing %ld byte file: .", flen );
  22257.     
  22258.     while( flen > READLEN )
  22259.     {
  22260.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  22261.         {
  22262.             printf("READ ERROR!\n");
  22263.             return;
  22264.         }
  22265.         MD5Translate( lpData, READLEN, &mdDataSum );
  22266.         MD4Translate( lpData, READLEN, &md4DataSum );
  22267.         flen -= READLEN;
  22268.         printf(".");
  22269.     }
  22270.  
  22271.     if (fread( lpData, 1, flen, file ) != flen)
  22272.     {
  22273.         printf("READ ERROR!\n");
  22274.         return;
  22275.     }
  22276.     // This is why I added the new argument to MDxPad
  22277.     // So we can pass the length of the data AND the
  22278.     // Total length of the message
  22279.     // Also it now returns the # of padding bytes added,
  22280.     // this is for files that are an exact multiple of the chunk
  22281.     // length. (Otherwise the padding isn't Translated)
  22282.     flen += MDxPad( lpData, flen, mlen );
  22283.     MD5Translate( lpData, flen, &mdDataSum );    
  22284.     MD4Translate( lpData, flen, &md4DataSum );
  22285.  
  22286.     // New step necessary because of the 'chunking' method
  22287.     MDxFinalize( &mdDataSum );
  22288.     MDxFinalize( &md4DataSum );
  22289.     
  22290.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  22291.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22292.     fclose(file);
  22293.         
  22294. }
  22295.  
  22296. void DigestString()
  22297. {
  22298.     
  22299.     //For our demo purposes, no strings bigger than 1024 :)
  22300.     unsigned char lpData[1024] = "";
  22301.     long len = 0;
  22302.     MDxSum mdDataSum;
  22303.  
  22304.     printf("Enter the string to digest: ");
  22305.     scanf("%s", &lpData );
  22306.     len = strlen(lpData);
  22307.     
  22308.     // Have to do this before the Padding...well...it's best anyway;)
  22309.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22310.     
  22311.     // For the strings, we're gonna pad and digest the string
  22312.     // in one pass.
  22313.     MDxInit( &mdDataSum );
  22314.     MDxPad( lpData, len, len );
  22315.     
  22316.     MD5Translate( lpData, len, &mdDataSum );
  22317.         // New step necessary because of the 'chunking' method
  22318.         MDxFinalize( &mdDataSum );
  22319.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22320.     
  22321.     MDxInit( &mdDataSum );
  22322.     MD4Translate( lpData, len, &mdDataSum );    
  22323.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22324.  
  22325.     return;
  22326. }
  22327.  
  22328.  
  22329. -------------- Include
  22330.  
  22331. #ifndef __windows_h__
  22332.         typedef unsigned long DWORD;
  22333.         #define STDCALL _stdcall
  22334. #endif
  22335.  
  22336. typedef struct 
  22337. {
  22338.     DWORD dwSum[4];
  22339. }MDxSum;
  22340.  
  22341. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22342. void STDCALL MDxInit( MDxSum * );
  22343. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22344. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22345. const char * STDCALL MDxGetVersion();
  22346. void STDCALL MDxFinalize( MDxSum * );
  22347.  
  22348.  
  22349.  
  22350.  
  22351. #include "mdx.h"
  22352. #include <stdlib.h>
  22353. #include <stdio.h>
  22354. #include <string.h>
  22355.  
  22356. // READLEN % 64 must = 0
  22357. #define READLEN    1048576L // 2^20, 1MB
  22358.  
  22359. void DigestFile( char * );
  22360. void DigestString();
  22361.  
  22362. void main(int argc, char *argv[])
  22363. {
  22364.     printf("%s\n\n", MDxGetVersion());
  22365.  
  22366.     if( argc > 1 )
  22367.         DigestFile( argv[1] );
  22368.     else    
  22369.         DigestString();
  22370.  
  22371. }
  22372.  
  22373. /*
  22374.     I use the 'chunk' method for processing files not because of
  22375.     limitations of my dll, but think what would happen if you
  22376.     tried to load an entire cd image into memory.
  22377. */
  22378. void DigestFile( char *szFName )
  22379. {
  22380.     FILE *file;
  22381.     void *lpData;
  22382.     long flen, mlen;
  22383.     MDxSum mdDataSum;
  22384.     MDxSum md4DataSum;
  22385.  
  22386.     // the 64 is for padding purposes
  22387.     lpData = malloc( READLEN + 64 );
  22388.     
  22389.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  22390.  
  22391.     file = fopen( szFName, "rb" );
  22392.     if( file == NULL )
  22393.     {
  22394.         printf("ERROR: File not found.\n");
  22395.         return;
  22396.     }
  22397.     
  22398.     MDxInit( &mdDataSum );
  22399.     MDxInit( &md4DataSum );
  22400.     
  22401.     fseek( file, 0, SEEK_END );
  22402.     //Get the file length
  22403.     flen = mlen = ftell( file );
  22404.     fseek( file, 0, SEEK_SET );
  22405.     
  22406.     // When it takes a while to process a large file,
  22407.     // remember that for each chunk it has to run 
  22408.     // through the main translation loop 16384 times!
  22409.         
  22410.     printf("Processing %ld byte file: .", flen );
  22411.     
  22412.     while( flen > READLEN )
  22413.     {
  22414.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  22415.         {
  22416.             printf("READ ERROR!\n");
  22417.             return;
  22418.         }
  22419.         MD5Translate( lpData, READLEN, &mdDataSum );
  22420.         MD4Translate( lpData, READLEN, &md4DataSum );
  22421.         flen -= READLEN;
  22422.         printf(".");
  22423.     }
  22424.  
  22425.     if (fread( lpData, 1, flen, file ) != flen)
  22426.     {
  22427.         printf("READ ERROR!\n");
  22428.         return;
  22429.     }
  22430.     // This is why I added the new argument to MDxPad
  22431.     // So we can pass the length of the data AND the
  22432.     // Total length of the message
  22433.     // Also it now returns the # of padding bytes added,
  22434.     // this is for files that are an exact multiple of the chunk
  22435.     // length. (Otherwise the padding isn't Translated)
  22436.     flen += MDxPad( lpData, flen, mlen );
  22437.     MD5Translate( lpData, flen, &mdDataSum );    
  22438.     MD4Translate( lpData, flen, &md4DataSum );
  22439.  
  22440.     // New step necessary because of the 'chunking' method
  22441.     MDxFinalize( &mdDataSum );
  22442.     MDxFinalize( &md4DataSum );
  22443.     
  22444.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  22445.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22446.     fclose(file);
  22447.         
  22448. }
  22449.  
  22450. void DigestString()
  22451. {
  22452.     
  22453.     //For our demo purposes, no strings bigger than 1024 :)
  22454.     unsigned char lpData[1024] = "";
  22455.     long len = 0;
  22456.     MDxSum mdDataSum;
  22457.  
  22458.     printf("Enter the string to digest: ");
  22459.     scanf("%s", &lpData );
  22460.     len = strlen(lpData);
  22461.     
  22462.     // Have to do this before the Padding...well...it's best anyway;)
  22463.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22464.     
  22465.     // For the strings, we're gonna pad and digest the string
  22466.     // in one pass.
  22467.     MDxInit( &mdDataSum );
  22468.     MDxPad( lpData, len, len );
  22469.     
  22470.     MD5Translate( lpData, len, &mdDataSum );
  22471.         // New step necessary because of the 'chunking' method
  22472.         MDxFinalize( &mdDataSum );
  22473.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22474.     
  22475.     MDxInit( &mdDataSum );
  22476.     MD4Translate( lpData, len, &mdDataSum );    
  22477.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22478.  
  22479.     return;
  22480. }
  22481.  
  22482.  
  22483. -------------- Include
  22484.  
  22485. #ifndef __windows_h__
  22486.         typedef unsigned long DWORD;
  22487.         #define STDCALL _stdcall
  22488. #endif
  22489.  
  22490. typedef struct 
  22491. {
  22492.     DWORD dwSum[4];
  22493. }MDxSum;
  22494.  
  22495. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22496. void STDCALL MDxInit( MDxSum * );
  22497. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22498. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22499. const char * STDCALL MDxGetVersion();
  22500. void STDCALL MDxFinalize( MDxSum * );
  22501.  
  22502.  
  22503.  
  22504.  
  22505. #include "mdx.h"
  22506. #include <stdlib.h>
  22507. #include <stdio.h>
  22508. #include <string.h>
  22509.  
  22510. // READLEN % 64 must = 0
  22511. #define READLEN    1048576L // 2^20, 1MB
  22512.  
  22513. void DigestFile( char * );
  22514. void DigestString();
  22515.  
  22516. void main(int argc, char *argv[])
  22517. {
  22518.     printf("%s\n\n", MDxGetVersion());
  22519.  
  22520.     if( argc > 1 )
  22521.         DigestFile( argv[1] );
  22522.     else    
  22523.         DigestString();
  22524.  
  22525. }
  22526.  
  22527. /*
  22528.     I use the 'chunk' method for processing files not because of
  22529.     limitations of my dll, but think what would happen if you
  22530.     tried to load an entire cd image into memory.
  22531. */
  22532. void DigestFile( char *szFName )
  22533. {
  22534.     FILE *file;
  22535.     void *lpData;
  22536.     long flen, mlen;
  22537.     MDxSum mdDataSum;
  22538.     MDxSum md4DataSum;
  22539.  
  22540.     // the 64 is for padding purposes
  22541.     lpData = malloc( READLEN + 64 );
  22542.     
  22543.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  22544.  
  22545.     file = fopen( szFName, "rb" );
  22546.     if( file == NULL )
  22547.     {
  22548.         printf("ERROR: File not found.\n");
  22549.         return;
  22550.     }
  22551.     
  22552.     MDxInit( &mdDataSum );
  22553.     MDxInit( &md4DataSum );
  22554.     
  22555.     fseek( file, 0, SEEK_END );
  22556.     //Get the file length
  22557.     flen = mlen = ftell( file );
  22558.     fseek( file, 0, SEEK_SET );
  22559.     
  22560.     // When it takes a while to process a large file,
  22561.     // remember that for each chunk it has to run 
  22562.     // through the main translation loop 16384 times!
  22563.         
  22564.     printf("Processing %ld byte file: .", flen );
  22565.     
  22566.     while( flen > READLEN )
  22567.     {
  22568.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  22569.         {
  22570.             printf("READ ERROR!\n");
  22571.             return;
  22572.         }
  22573.         MD5Translate( lpData, READLEN, &mdDataSum );
  22574.         MD4Translate( lpData, READLEN, &md4DataSum );
  22575.         flen -= READLEN;
  22576.         printf(".");
  22577.     }
  22578.  
  22579.     if (fread( lpData, 1, flen, file ) != flen)
  22580.     {
  22581.         printf("READ ERROR!\n");
  22582.         return;
  22583.     }
  22584.     // This is why I added the new argument to MDxPad
  22585.     // So we can pass the length of the data AND the
  22586.     // Total length of the message
  22587.     // Also it now returns the # of padding bytes added,
  22588.     // this is for files that are an exact multiple of the chunk
  22589.     // length. (Otherwise the padding isn't Translated)
  22590.     flen += MDxPad( lpData, flen, mlen );
  22591.     MD5Translate( lpData, flen, &mdDataSum );    
  22592.     MD4Translate( lpData, flen, &md4DataSum );
  22593.  
  22594.     // New step necessary because of the 'chunking' method
  22595.     MDxFinalize( &mdDataSum );
  22596.     MDxFinalize( &md4DataSum );
  22597.     
  22598.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  22599.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22600.     fclose(file);
  22601.         
  22602. }
  22603.  
  22604. void DigestString()
  22605. {
  22606.     
  22607.     //For our demo purposes, no strings bigger than 1024 :)
  22608.     unsigned char lpData[1024] = "";
  22609.     long len = 0;
  22610.     MDxSum mdDataSum;
  22611.  
  22612.     printf("Enter the string to digest: ");
  22613.     scanf("%s", &lpData );
  22614.     len = strlen(lpData);
  22615.     
  22616.     // Have to do this before the Padding...well...it's best anyway;)
  22617.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22618.     
  22619.     // For the strings, we're gonna pad and digest the string
  22620.     // in one pass.
  22621.     MDxInit( &mdDataSum );
  22622.     MDxPad( lpData, len, len );
  22623.     
  22624.     MD5Translate( lpData, len, &mdDataSum );
  22625.         // New step necessary because of the 'chunking' method
  22626.         MDxFinalize( &mdDataSum );
  22627.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22628.     
  22629.     MDxInit( &mdDataSum );
  22630.     MD4Translate( lpData, len, &mdDataSum );    
  22631.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22632.  
  22633.     return;
  22634. }
  22635.  
  22636.  
  22637. -------------- Include
  22638.  
  22639. #ifndef __windows_h__
  22640.         typedef unsigned long DWORD;
  22641.         #define STDCALL _stdcall
  22642. #endif
  22643.  
  22644. typedef struct 
  22645. {
  22646.     DWORD dwSum[4];
  22647. }MDxSum;
  22648.  
  22649. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22650. void STDCALL MDxInit( MDxSum * );
  22651. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22652. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22653. const char * STDCALL MDxGetVersion();
  22654. void STDCALL MDxFinalize( MDxSum * );
  22655.  
  22656.  
  22657.  
  22658.  
  22659. #include "mdx.h"
  22660. #include <stdlib.h>
  22661. #include <stdio.h>
  22662. #include <string.h>
  22663.  
  22664. // READLEN % 64 must = 0
  22665. #define READLEN    1048576L // 2^20, 1MB
  22666.  
  22667. void DigestFile( char * );
  22668. void DigestString();
  22669.  
  22670. void main(int argc, char *argv[])
  22671. {
  22672.     printf("%s\n\n", MDxGetVersion());
  22673.  
  22674.     if( argc > 1 )
  22675.         DigestFile( argv[1] );
  22676.     else    
  22677.         DigestString();
  22678.  
  22679. }
  22680.  
  22681. /*
  22682.     I use the 'chunk' method for processing files not because of
  22683.     limitations of my dll, but think what would happen if you
  22684.     tried to load an entire cd image into memory.
  22685. */
  22686. void DigestFile( char *szFName )
  22687. {
  22688.     FILE *file;
  22689.     void *lpData;
  22690.     long flen, mlen;
  22691.     MDxSum mdDataSum;
  22692.     MDxSum md4DataSum;
  22693.  
  22694.     // the 64 is for padding purposes
  22695.     lpData = malloc( READLEN + 64 );
  22696.     
  22697.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  22698.  
  22699.     file = fopen( szFName, "rb" );
  22700.     if( file == NULL )
  22701.     {
  22702.         printf("ERROR: File not found.\n");
  22703.         return;
  22704.     }
  22705.     
  22706.     MDxInit( &mdDataSum );
  22707.     MDxInit( &md4DataSum );
  22708.     
  22709.     fseek( file, 0, SEEK_END );
  22710.     //Get the file length
  22711.     flen = mlen = ftell( file );
  22712.     fseek( file, 0, SEEK_SET );
  22713.     
  22714.     // When it takes a while to process a large file,
  22715.     // remember that for each chunk it has to run 
  22716.     // through the main translation loop 16384 times!
  22717.         
  22718.     printf("Processing %ld byte file: .", flen );
  22719.     
  22720.     while( flen > READLEN )
  22721.     {
  22722.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  22723.         {
  22724.             printf("READ ERROR!\n");
  22725.             return;
  22726.         }
  22727.         MD5Translate( lpData, READLEN, &mdDataSum );
  22728.         MD4Translate( lpData, READLEN, &md4DataSum );
  22729.         flen -= READLEN;
  22730.         printf(".");
  22731.     }
  22732.  
  22733.     if (fread( lpData, 1, flen, file ) != flen)
  22734.     {
  22735.         printf("READ ERROR!\n");
  22736.         return;
  22737.     }
  22738.     // This is why I added the new argument to MDxPad
  22739.     // So we can pass the length of the data AND the
  22740.     // Total length of the message
  22741.     // Also it now returns the # of padding bytes added,
  22742.     // this is for files that are an exact multiple of the chunk
  22743.     // length. (Otherwise the padding isn't Translated)
  22744.     flen += MDxPad( lpData, flen, mlen );
  22745.     MD5Translate( lpData, flen, &mdDataSum );    
  22746.     MD4Translate( lpData, flen, &md4DataSum );
  22747.  
  22748.     // New step necessary because of the 'chunking' method
  22749.     MDxFinalize( &mdDataSum );
  22750.     MDxFinalize( &md4DataSum );
  22751.     
  22752.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  22753.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22754.     fclose(file);
  22755.         
  22756. }
  22757.  
  22758. void DigestString()
  22759. {
  22760.     
  22761.     //For our demo purposes, no strings bigger than 1024 :)
  22762.     unsigned char lpData[1024] = "";
  22763.     long len = 0;
  22764.     MDxSum mdDataSum;
  22765.  
  22766.     printf("Enter the string to digest: ");
  22767.     scanf("%s", &lpData );
  22768.     len = strlen(lpData);
  22769.     
  22770.     // Have to do this before the Padding...well...it's best anyway;)
  22771.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22772.     
  22773.     // For the strings, we're gonna pad and digest the string
  22774.     // in one pass.
  22775.     MDxInit( &mdDataSum );
  22776.     MDxPad( lpData, len, len );
  22777.     
  22778.     MD5Translate( lpData, len, &mdDataSum );
  22779.         // New step necessary because of the 'chunking' method
  22780.         MDxFinalize( &mdDataSum );
  22781.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22782.     
  22783.     MDxInit( &mdDataSum );
  22784.     MD4Translate( lpData, len, &mdDataSum );    
  22785.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22786.  
  22787.     return;
  22788. }
  22789.  
  22790.  
  22791. -------------- Include
  22792.  
  22793. #ifndef __windows_h__
  22794.         typedef unsigned long DWORD;
  22795.         #define STDCALL _stdcall
  22796. #endif
  22797.  
  22798. typedef struct 
  22799. {
  22800.     DWORD dwSum[4];
  22801. }MDxSum;
  22802.  
  22803. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22804. void STDCALL MDxInit( MDxSum * );
  22805. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22806. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22807. const char * STDCALL MDxGetVersion();
  22808. void STDCALL MDxFinalize( MDxSum * );
  22809.  
  22810.  
  22811.  
  22812. #include "mdx.h"
  22813. #include <stdlib.h>
  22814. #include <stdio.h>
  22815. #include <string.h>
  22816.  
  22817. // READLEN % 64 must = 0
  22818. #define READLEN    1048576L // 2^20, 1MB
  22819.  
  22820. void DigestFile( char * );
  22821. void DigestString();
  22822.  
  22823. void main(int argc, char *argv[])
  22824. {
  22825.     printf("%s\n\n", MDxGetVersion());
  22826.  
  22827.     if( argc > 1 )
  22828.         DigestFile( argv[1] );
  22829.     else    
  22830.         DigestString();
  22831.  
  22832. }
  22833.  
  22834. /*
  22835.     I use the 'chunk' method for processing files not because of
  22836.     limitations of my dll, but think what would happen if you
  22837.     tried to load an entire cd image into memory.
  22838. */
  22839. void DigestFile( char *szFName )
  22840. {
  22841.     FILE *file;
  22842.     void *lpData;
  22843.     long flen, mlen;
  22844.     MDxSum mdDataSum;
  22845.     MDxSum md4DataSum;
  22846.  
  22847.     // the 64 is for padding purposes
  22848.     lpData = malloc( READLEN + 64 );
  22849.     
  22850.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  22851.  
  22852.     file = fopen( szFName, "rb" );
  22853.     if( file == NULL )
  22854.     {
  22855.         printf("ERROR: File not found.\n");
  22856.         return;
  22857.     }
  22858.     
  22859.     MDxInit( &mdDataSum );
  22860.     MDxInit( &md4DataSum );
  22861.     
  22862.     fseek( file, 0, SEEK_END );
  22863.     //Get the file length
  22864.     flen = mlen = ftell( file );
  22865.     fseek( file, 0, SEEK_SET );
  22866.     
  22867.     // When it takes a while to process a large file,
  22868.     // remember that for each chunk it has to run 
  22869.     // through the main translation loop 16384 times!
  22870.         
  22871.     printf("Processing %ld byte file: .", flen );
  22872.     
  22873.     while( flen > READLEN )
  22874.     {
  22875.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  22876.         {
  22877.             printf("READ ERROR!\n");
  22878.             return;
  22879.         }
  22880.         MD5Translate( lpData, READLEN, &mdDataSum );
  22881.         MD4Translate( lpData, READLEN, &md4DataSum );
  22882.         flen -= READLEN;
  22883.         printf(".");
  22884.     }
  22885.  
  22886.     if (fread( lpData, 1, flen, file ) != flen)
  22887.     {
  22888.         printf("READ ERROR!\n");
  22889.         return;
  22890.     }
  22891.     // This is why I added the new argument to MDxPad
  22892.     // So we can pass the length of the data AND the
  22893.     // Total length of the message
  22894.     // Also it now returns the # of padding bytes added,
  22895.     // this is for files that are an exact multiple of the chunk
  22896.     // length. (Otherwise the padding isn't Translated)
  22897.     flen += MDxPad( lpData, flen, mlen );
  22898.     MD5Translate( lpData, flen, &mdDataSum );    
  22899.     MD4Translate( lpData, flen, &md4DataSum );
  22900.  
  22901.     // New step necessary because of the 'chunking' method
  22902.     MDxFinalize( &mdDataSum );
  22903.     MDxFinalize( &md4DataSum );
  22904.     
  22905.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  22906.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22907.     fclose(file);
  22908.         
  22909. }
  22910.  
  22911. void DigestString()
  22912. {
  22913.     
  22914.     //For our demo purposes, no strings bigger than 1024 :)
  22915.     unsigned char lpData[1024] = "";
  22916.     long len = 0;
  22917.     MDxSum mdDataSum;
  22918.  
  22919.     printf("Enter the string to digest: ");
  22920.     scanf("%s", &lpData );
  22921.     len = strlen(lpData);
  22922.     
  22923.     // Have to do this before the Padding...well...it's best anyway;)
  22924.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  22925.     
  22926.     // For the strings, we're gonna pad and digest the string
  22927.     // in one pass.
  22928.     MDxInit( &mdDataSum );
  22929.     MDxPad( lpData, len, len );
  22930.     
  22931.     MD5Translate( lpData, len, &mdDataSum );
  22932.         // New step necessary because of the 'chunking' method
  22933.         MDxFinalize( &mdDataSum );
  22934.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22935.     
  22936.     MDxInit( &mdDataSum );
  22937.     MD4Translate( lpData, len, &mdDataSum );    
  22938.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  22939.  
  22940.     return;
  22941. }
  22942.  
  22943.  
  22944. -------------- Include
  22945.  
  22946. #ifndef __windows_h__
  22947.         typedef unsigned long DWORD;
  22948.         #define STDCALL _stdcall
  22949. #endif
  22950.  
  22951. typedef struct 
  22952. {
  22953.     DWORD dwSum[4];
  22954. }MDxSum;
  22955.  
  22956. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  22957. void STDCALL MDxInit( MDxSum * );
  22958. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  22959. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  22960. const char * STDCALL MDxGetVersion();
  22961. void STDCALL MDxFinalize( MDxSum * );
  22962.  
  22963.  
  22964.  
  22965. #include "mdx.h"
  22966. #include <stdlib.h>
  22967. #include <stdio.h>
  22968. #include <string.h>
  22969.  
  22970. // READLEN % 64 must = 0
  22971. #define READLEN    1048576L // 2^20, 1MB
  22972.  
  22973. void DigestFile( char * );
  22974. void DigestString();
  22975.  
  22976. void main(int argc, char *argv[])
  22977. {
  22978.     printf("%s\n\n", MDxGetVersion());
  22979.  
  22980.     if( argc > 1 )
  22981.         DigestFile( argv[1] );
  22982.     else    
  22983.         DigestString();
  22984.  
  22985. }
  22986.  
  22987. /*
  22988.     I use the 'chunk' method for processing files not because of
  22989.     limitations of my dll, but think what would happen if you
  22990.     tried to load an entire cd image into memory.
  22991. */
  22992. void DigestFile( char *szFName )
  22993. {
  22994.     FILE *file;
  22995.     void *lpData;
  22996.     long flen, mlen;
  22997.     MDxSum mdDataSum;
  22998.     MDxSum md4DataSum;
  22999.  
  23000.     // the 64 is for padding purposes
  23001.     lpData = malloc( READLEN + 64 );
  23002.     
  23003.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23004.  
  23005.     file = fopen( szFName, "rb" );
  23006.     if( file == NULL )
  23007.     {
  23008.         printf("ERROR: File not found.\n");
  23009.         return;
  23010.     }
  23011.     
  23012.     MDxInit( &mdDataSum );
  23013.     MDxInit( &md4DataSum );
  23014.     
  23015.     fseek( file, 0, SEEK_END );
  23016.     //Get the file length
  23017.     flen = mlen = ftell( file );
  23018.     fseek( file, 0, SEEK_SET );
  23019.     
  23020.     // When it takes a while to process a large file,
  23021.     // remember that for each chunk it has to run 
  23022.     // through the main translation loop 16384 times!
  23023.         
  23024.     printf("Processing %ld byte file: .", flen );
  23025.     
  23026.     while( flen > READLEN )
  23027.     {
  23028.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23029.         {
  23030.             printf("READ ERROR!\n");
  23031.             return;
  23032.         }
  23033.         MD5Translate( lpData, READLEN, &mdDataSum );
  23034.         MD4Translate( lpData, READLEN, &md4DataSum );
  23035.         flen -= READLEN;
  23036.         printf(".");
  23037.     }
  23038.  
  23039.     if (fread( lpData, 1, flen, file ) != flen)
  23040.     {
  23041.         printf("READ ERROR!\n");
  23042.         return;
  23043.     }
  23044.     // This is why I added the new argument to MDxPad
  23045.     // So we can pass the length of the data AND the
  23046.     // Total length of the message
  23047.     // Also it now returns the # of padding bytes added,
  23048.     // this is for files that are an exact multiple of the chunk
  23049.     // length. (Otherwise the padding isn't Translated)
  23050.     flen += MDxPad( lpData, flen, mlen );
  23051.     MD5Translate( lpData, flen, &mdDataSum );    
  23052.     MD4Translate( lpData, flen, &md4DataSum );
  23053.  
  23054.     // New step necessary because of the 'chunking' method
  23055.     MDxFinalize( &mdDataSum );
  23056.     MDxFinalize( &md4DataSum );
  23057.     
  23058.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23059.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23060.     fclose(file);
  23061.         
  23062. }
  23063.  
  23064. void DigestString()
  23065. {
  23066.     
  23067.     //For our demo purposes, no strings bigger than 1024 :)
  23068.     unsigned char lpData[1024] = "";
  23069.     long len = 0;
  23070.     MDxSum mdDataSum;
  23071.  
  23072.     printf("Enter the string to digest: ");
  23073.     scanf("%s", &lpData );
  23074.     len = strlen(lpData);
  23075.     
  23076.     // Have to do this before the Padding...well...it's best anyway;)
  23077.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23078.     
  23079.     // For the strings, we're gonna pad and digest the string
  23080.     // in one pass.
  23081.     MDxInit( &mdDataSum );
  23082.     MDxPad( lpData, len, len );
  23083.     
  23084.     MD5Translate( lpData, len, &mdDataSum );
  23085.         // New step necessary because of the 'chunking' method
  23086.         MDxFinalize( &mdDataSum );
  23087.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23088.     
  23089.     MDxInit( &mdDataSum );
  23090.     MD4Translate( lpData, len, &mdDataSum );    
  23091.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23092.  
  23093.     return;
  23094. }
  23095.  
  23096.  
  23097. -------------- Include
  23098.  
  23099. #ifndef __windows_h__
  23100.         typedef unsigned long DWORD;
  23101.         #define STDCALL _stdcall
  23102. #endif
  23103.  
  23104. typedef struct 
  23105. {
  23106.     DWORD dwSum[4];
  23107. }MDxSum;
  23108.  
  23109. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  23110. void STDCALL MDxInit( MDxSum * );
  23111. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  23112. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  23113. const char * STDCALL MDxGetVersion();
  23114. void STDCALL MDxFinalize( MDxSum * );
  23115.  
  23116.  
  23117.  
  23118.  
  23119. #include "mdx.h"
  23120. #include <stdlib.h>
  23121. #include <stdio.h>
  23122. #include <string.h>
  23123.  
  23124. // READLEN % 64 must = 0
  23125. #define READLEN    1048576L // 2^20, 1MB
  23126.  
  23127. void DigestFile( char * );
  23128. void DigestString();
  23129.  
  23130. void main(int argc, char *argv[])
  23131. {
  23132.     printf("%s\n\n", MDxGetVersion());
  23133.  
  23134.     if( argc > 1 )
  23135.         DigestFile( argv[1] );
  23136.     else    
  23137.         DigestString();
  23138.  
  23139. }
  23140.  
  23141. /*
  23142.     I use the 'chunk' method for processing files not because of
  23143.     limitations of my dll, but think what would happen if you
  23144.     tried to load an entire cd image into memory.
  23145. */
  23146. void DigestFile( char *szFName )
  23147. {
  23148.     FILE *file;
  23149.     void *lpData;
  23150.     long flen, mlen;
  23151.     MDxSum mdDataSum;
  23152.     MDxSum md4DataSum;
  23153.  
  23154.     // the 64 is for padding purposes
  23155.     lpData = malloc( READLEN + 64 );
  23156.     
  23157.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23158.  
  23159.     file = fopen( szFName, "rb" );
  23160.     if( file == NULL )
  23161.     {
  23162.         printf("ERROR: File not found.\n");
  23163.         return;
  23164.     }
  23165.     
  23166.     MDxInit( &mdDataSum );
  23167.     MDxInit( &md4DataSum );
  23168.     
  23169.     fseek( file, 0, SEEK_END );
  23170.     //Get the file length
  23171.     flen = mlen = ftell( file );
  23172.     fseek( file, 0, SEEK_SET );
  23173.     
  23174.     // When it takes a while to process a large file,
  23175.     // remember that for each chunk it has to run 
  23176.     // through the main translation loop 16384 times!
  23177.         
  23178.     printf("Processing %ld byte file: .", flen );
  23179.     
  23180.     while( flen > READLEN )
  23181.     {
  23182.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23183.         {
  23184.             printf("READ ERROR!\n");
  23185.             return;
  23186.         }
  23187.         MD5Translate( lpData, READLEN, &mdDataSum );
  23188.         MD4Translate( lpData, READLEN, &md4DataSum );
  23189.         flen -= READLEN;
  23190.         printf(".");
  23191.     }
  23192.  
  23193.     if (fread( lpData, 1, flen, file ) != flen)
  23194.     {
  23195.         printf("READ ERROR!\n");
  23196.         return;
  23197.     }
  23198.     // This is why I added the new argument to MDxPad
  23199.     // So we can pass the length of the data AND the
  23200.     // Total length of the message
  23201.     // Also it now returns the # of padding bytes added,
  23202.     // this is for files that are an exact multiple of the chunk
  23203.     // length. (Otherwise the padding isn't Translated)
  23204.     flen += MDxPad( lpData, flen, mlen );
  23205.     MD5Translate( lpData, flen, &mdDataSum );    
  23206.     MD4Translate( lpData, flen, &md4DataSum );
  23207.  
  23208.     // New step necessary because of the 'chunking' method
  23209.     MDxFinalize( &mdDataSum );
  23210.     MDxFinalize( &md4DataSum );
  23211.     
  23212.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23213.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23214.     fclose(file);
  23215.         
  23216. }
  23217.  
  23218. void DigestString()
  23219. {
  23220.     
  23221.     //For our demo purposes, no strings bigger than 1024 :)
  23222.     unsigned char lpData[1024] = "";
  23223.     long len = 0;
  23224.     MDxSum mdDataSum;
  23225.  
  23226.     printf("Enter the string to digest: ");
  23227.     scanf("%s", &lpData );
  23228.     len = strlen(lpData);
  23229.     
  23230.     // Have to do this before the Padding...well...it's best anyway;)
  23231.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23232.     
  23233.     // For the strings, we're gonna pad and digest the string
  23234.     // in one pass.
  23235.     MDxInit( &mdDataSum );
  23236.     MDxPad( lpData, len, len );
  23237.     
  23238.     MD5Translate( lpData, len, &mdDataSum );
  23239.         // New step necessary because of the 'chunking' method
  23240.         MDxFinalize( &mdDataSum );
  23241.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23242.     
  23243.     MDxInit( &mdDataSum );
  23244.     MD4Translate( lpData, len, &mdDataSum );    
  23245.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23246.  
  23247.     return;
  23248. }
  23249.  
  23250.  
  23251. -------------- Include
  23252.  
  23253. #ifndef __windows_h__
  23254.         typedef unsigned long DWORD;
  23255.         #define STDCALL _stdcall
  23256. #endif
  23257.  
  23258. typedef struct 
  23259. {
  23260.     DWORD dwSum[4];
  23261. }MDxSum;
  23262.  
  23263. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  23264. void STDCALL MDxInit( MDxSum * );
  23265. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  23266. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  23267. const char * STDCALL MDxGetVersion();
  23268. void STDCALL MDxFinalize( MDxSum * );
  23269.  
  23270.  
  23271.  
  23272. #include "mdx.h"
  23273. #include <stdlib.h>
  23274. #include <stdio.h>
  23275. #include <string.h>
  23276.  
  23277. // READLEN % 64 must = 0
  23278. #define READLEN    1048576L // 2^20, 1MB
  23279.  
  23280. void DigestFile( char * );
  23281. void DigestString();
  23282.  
  23283. void main(int argc, char *argv[])
  23284. {
  23285.     printf("%s\n\n", MDxGetVersion());
  23286.  
  23287.     if( argc > 1 )
  23288.         DigestFile( argv[1] );
  23289.     else    
  23290.         DigestString();
  23291.  
  23292. }
  23293.  
  23294. /*
  23295.     I use the 'chunk' method for processing files not because of
  23296.     limitations of my dll, but think what would happen if you
  23297.     tried to load an entire cd image into memory.
  23298. */
  23299. void DigestFile( char *szFName )
  23300. {
  23301.     FILE *file;
  23302.     void *lpData;
  23303.     long flen, mlen;
  23304.     MDxSum mdDataSum;
  23305.     MDxSum md4DataSum;
  23306.  
  23307.     // the 64 is for padding purposes
  23308.     lpData = malloc( READLEN + 64 );
  23309.     
  23310.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23311.  
  23312.     file = fopen( szFName, "rb" );
  23313.     if( file == NULL )
  23314.     {
  23315.         printf("ERROR: File not found.\n");
  23316.         return;
  23317.     }
  23318.     
  23319.     MDxInit( &mdDataSum );
  23320.     MDxInit( &md4DataSum );
  23321.     
  23322.     fseek( file, 0, SEEK_END );
  23323.     //Get the file length
  23324.     flen = mlen = ftell( file );
  23325.     fseek( file, 0, SEEK_SET );
  23326.     
  23327.     // When it takes a while to process a large file,
  23328.     // remember that for each chunk it has to run 
  23329.     // through the main translation loop 16384 times!
  23330.         
  23331.     printf("Processing %ld byte file: .", flen );
  23332.     
  23333.     while( flen > READLEN )
  23334.     {
  23335.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23336.         {
  23337.             printf("READ ERROR!\n");
  23338.             return;
  23339.         }
  23340.         MD5Translate( lpData, READLEN, &mdDataSum );
  23341.         MD4Translate( lpData, READLEN, &md4DataSum );
  23342.         flen -= READLEN;
  23343.         printf(".");
  23344.     }
  23345.  
  23346.     if (fread( lpData, 1, flen, file ) != flen)
  23347.     {
  23348.         printf("READ ERROR!\n");
  23349.         return;
  23350.     }
  23351.     // This is why I added the new argument to MDxPad
  23352.     // So we can pass the length of the data AND the
  23353.     // Total length of the message
  23354.     // Also it now returns the # of padding bytes added,
  23355.     // this is for files that are an exact multiple of the chunk
  23356.     // length. (Otherwise the padding isn't Translated)
  23357.     flen += MDxPad( lpData, flen, mlen );
  23358.     MD5Translate( lpData, flen, &mdDataSum );    
  23359.     MD4Translate( lpData, flen, &md4DataSum );
  23360.  
  23361.     // New step necessary because of the 'chunking' method
  23362.     MDxFinalize( &mdDataSum );
  23363.     MDxFinalize( &md4DataSum );
  23364.     
  23365.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23366.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23367.     fclose(file);
  23368.         
  23369. }
  23370.  
  23371. void DigestString()
  23372. {
  23373.     
  23374.     //For our demo purposes, no strings bigger than 1024 :)
  23375.     unsigned char lpData[1024] = "";
  23376.     long len = 0;
  23377.     MDxSum mdDataSum;
  23378.  
  23379.     printf("Enter the string to digest: ");
  23380.     scanf("%s", &lpData );
  23381.     len = strlen(lpData);
  23382.     
  23383.     // Have to do this before the Padding...well...it's best anyway;)
  23384.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23385.     
  23386.     // For the strings, we're gonna pad and digest the string
  23387.     // in one pass.
  23388.     MDxInit( &mdDataSum );
  23389.     MDxPad( lpData, len, len );
  23390.     
  23391.     MD5Translate( lpData, len, &mdDataSum );
  23392.         // New step necessary because of the 'chunking' method
  23393.         MDxFinalize( &mdDataSum );
  23394.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23395.     
  23396.     MDxInit( &mdDataSum );
  23397.     MD4Translate( lpData, len, &mdDataSum );    
  23398.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23399.  
  23400.     return;
  23401. }
  23402.  
  23403.  
  23404. -------------- Include
  23405.  
  23406. #ifndef __windows_h__
  23407.         typedef unsigned long DWORD;
  23408.         #define STDCALL _stdcall
  23409. #endif
  23410.  
  23411. typedef struct 
  23412. {
  23413.     DWORD dwSum[4];
  23414. }MDxSum;
  23415.  
  23416. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  23417. void STDCALL MDxInit( MDxSum * );
  23418. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  23419. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  23420. const char * STDCALL MDxGetVersion();
  23421. void STDCALL MDxFinalize( MDxSum * );
  23422.  
  23423.  
  23424.  
  23425.  
  23426. #include "mdx.h"
  23427. #include <stdlib.h>
  23428. #include <stdio.h>
  23429. #include <string.h>
  23430.  
  23431. // READLEN % 64 must = 0
  23432. #define READLEN    1048576L // 2^20, 1MB
  23433.  
  23434. void DigestFile( char * );
  23435. void DigestString();
  23436.  
  23437. void main(int argc, char *argv[])
  23438. {
  23439.     printf("%s\n\n", MDxGetVersion());
  23440.  
  23441.     if( argc > 1 )
  23442.         DigestFile( argv[1] );
  23443.     else    
  23444.         DigestString();
  23445.  
  23446. }
  23447.  
  23448. /*
  23449.     I use the 'chunk' method for processing files not because of
  23450.     limitations of my dll, but think what would happen if you
  23451.     tried to load an entire cd image into memory.
  23452. */
  23453. void DigestFile( char *szFName )
  23454. {
  23455.     FILE *file;
  23456.     void *lpData;
  23457.     long flen, mlen;
  23458.     MDxSum mdDataSum;
  23459.     MDxSum md4DataSum;
  23460.  
  23461.     // the 64 is for padding purposes
  23462.     lpData = malloc( READLEN + 64 );
  23463.     
  23464.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23465.  
  23466.     file = fopen( szFName, "rb" );
  23467.     if( file == NULL )
  23468.     {
  23469.         printf("ERROR: File not found.\n");
  23470.         return;
  23471.     }
  23472.     
  23473.     MDxInit( &mdDataSum );
  23474.     MDxInit( &md4DataSum );
  23475.     
  23476.     fseek( file, 0, SEEK_END );
  23477.     //Get the file length
  23478.     flen = mlen = ftell( file );
  23479.     fseek( file, 0, SEEK_SET );
  23480.     
  23481.     // When it takes a while to process a large file,
  23482.     // remember that for each chunk it has to run 
  23483.     // through the main translation loop 16384 times!
  23484.         
  23485.     printf("Processing %ld byte file: .", flen );
  23486.     
  23487.     while( flen > READLEN )
  23488.     {
  23489.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23490.         {
  23491.             printf("READ ERROR!\n");
  23492.             return;
  23493.         }
  23494.         MD5Translate( lpData, READLEN, &mdDataSum );
  23495.         MD4Translate( lpData, READLEN, &md4DataSum );
  23496.         flen -= READLEN;
  23497.         printf(".");
  23498.     }
  23499.  
  23500.     if (fread( lpData, 1, flen, file ) != flen)
  23501.     {
  23502.         printf("READ ERROR!\n");
  23503.         return;
  23504.     }
  23505.     // This is why I added the new argument to MDxPad
  23506.     // So we can pass the length of the data AND the
  23507.     // Total length of the message
  23508.     // Also it now returns the # of padding bytes added,
  23509.     // this is for files that are an exact multiple of the chunk
  23510.     // length. (Otherwise the padding isn't Translated)
  23511.     flen += MDxPad( lpData, flen, mlen );
  23512.     MD5Translate( lpData, flen, &mdDataSum );    
  23513.     MD4Translate( lpData, flen, &md4DataSum );
  23514.  
  23515.     // New step necessary because of the 'chunking' method
  23516.     MDxFinalize( &mdDataSum );
  23517.     MDxFinalize( &md4DataSum );
  23518.     
  23519.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23520.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23521.     fclose(file);
  23522.         
  23523. }
  23524.  
  23525. void DigestString()
  23526. {
  23527.     
  23528.     //For our demo purposes, no strings bigger than 1024 :)
  23529.     unsigned char lpData[1024] = "";
  23530.     long len = 0;
  23531.     MDxSum mdDataSum;
  23532.  
  23533.     printf("Enter the string to digest: ");
  23534.     scanf("%s", &lpData );
  23535.     len = strlen(lpData);
  23536.     
  23537.     // Have to do this before the Padding...well...it's best anyway;)
  23538.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23539.     
  23540.     // For the strings, we're gonna pad and digest the string
  23541.     // in one pass.
  23542.     MDxInit( &mdDataSum );
  23543.     MDxPad( lpData, len, len );
  23544.     
  23545.     MD5Translate( lpData, len, &mdDataSum );
  23546.         // New step necessary because of the 'chunking' method
  23547.         MDxFinalize( &mdDataSum );
  23548.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23549.     
  23550.     MDxInit( &mdDataSum );
  23551.     MD4Translate( lpData, len, &mdDataSum );    
  23552.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23553.  
  23554.     return;
  23555. }
  23556.  
  23557.  
  23558. -------------- Include
  23559.  
  23560. #ifndef __windows_h__
  23561.         typedef unsigned long DWORD;
  23562.         #define STDCALL _stdcall
  23563. #endif
  23564.  
  23565. typedef struct 
  23566. {
  23567.     DWORD dwSum[4];
  23568. }MDxSum;
  23569.  
  23570. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  23571. void STDCALL MDxInit( MDxSum * );
  23572. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  23573. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  23574. const char * STDCALL MDxGetVersion();
  23575. void STDCALL MDxFinalize( MDxSum * );
  23576.  
  23577.  
  23578.  
  23579.  
  23580. #include "mdx.h"
  23581. #include <stdlib.h>
  23582. #include <stdio.h>
  23583. #include <string.h>
  23584.  
  23585. // READLEN % 64 must = 0
  23586. #define READLEN    1048576L // 2^20, 1MB
  23587.  
  23588. void DigestFile( char * );
  23589. void DigestString();
  23590.  
  23591. void main(int argc, char *argv[])
  23592. {
  23593.     printf("%s\n\n", MDxGetVersion());
  23594.  
  23595.     if( argc > 1 )
  23596.         DigestFile( argv[1] );
  23597.     else    
  23598.         DigestString();
  23599.  
  23600. }
  23601.  
  23602. /*
  23603.     I use the 'chunk' method for processing files not because of
  23604.     limitations of my dll, but think what would happen if you
  23605.     tried to load an entire cd image into memory.
  23606. */
  23607. void DigestFile( char *szFName )
  23608. {
  23609.     FILE *file;
  23610.     void *lpData;
  23611.     long flen, mlen;
  23612.     MDxSum mdDataSum;
  23613.     MDxSum md4DataSum;
  23614.  
  23615.     // the 64 is for padding purposes
  23616.     lpData = malloc( READLEN + 64 );
  23617.     
  23618.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23619.  
  23620.     file = fopen( szFName, "rb" );
  23621.     if( file == NULL )
  23622.     {
  23623.         printf("ERROR: File not found.\n");
  23624.         return;
  23625.     }
  23626.     
  23627.     MDxInit( &mdDataSum );
  23628.     MDxInit( &md4DataSum );
  23629.     
  23630.     fseek( file, 0, SEEK_END );
  23631.     //Get the file length
  23632.     flen = mlen = ftell( file );
  23633.     fseek( file, 0, SEEK_SET );
  23634.     
  23635.     // When it takes a while to process a large file,
  23636.     // remember that for each chunk it has to run 
  23637.     // through the main translation loop 16384 times!
  23638.         
  23639.     printf("Processing %ld byte file: .", flen );
  23640.     
  23641.     while( flen > READLEN )
  23642.     {
  23643.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23644.         {
  23645.             printf("READ ERROR!\n");
  23646.             return;
  23647.         }
  23648.         MD5Translate( lpData, READLEN, &mdDataSum );
  23649.         MD4Translate( lpData, READLEN, &md4DataSum );
  23650.         flen -= READLEN;
  23651.         printf(".");
  23652.     }
  23653.  
  23654.     if (fread( lpData, 1, flen, file ) != flen)
  23655.     {
  23656.         printf("READ ERROR!\n");
  23657.         return;
  23658.     }
  23659.     // This is why I added the new argument to MDxPad
  23660.     // So we can pass the length of the data AND the
  23661.     // Total length of the message
  23662.     // Also it now returns the # of padding bytes added,
  23663.     // this is for files that are an exact multiple of the chunk
  23664.     // length. (Otherwise the padding isn't Translated)
  23665.     flen += MDxPad( lpData, flen, mlen );
  23666.     MD5Translate( lpData, flen, &mdDataSum );    
  23667.     MD4Translate( lpData, flen, &md4DataSum );
  23668.  
  23669.     // New step necessary because of the 'chunking' method
  23670.     MDxFinalize( &mdDataSum );
  23671.     MDxFinalize( &md4DataSum );
  23672.     
  23673.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23674.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23675.     fclose(file);
  23676.         
  23677. }
  23678.  
  23679. void DigestString()
  23680. {
  23681.     
  23682.     //For our demo purposes, no strings bigger than 1024 :)
  23683.     unsigned char lpData[1024] = "";
  23684.     long len = 0;
  23685.     MDxSum mdDataSum;
  23686.  
  23687.     printf("Enter the string to digest: ");
  23688.     scanf("%s", &lpData );
  23689.     len = strlen(lpData);
  23690.     
  23691.     // Have to do this before the Padding...well...it's best anyway;)
  23692.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23693.     
  23694.     // For the strings, we're gonna pad and digest the string
  23695.     // in one pass.
  23696.     MDxInit( &mdDataSum );
  23697.     MDxPad( lpData, len, len );
  23698.     
  23699.     MD5Translate( lpData, len, &mdDataSum );
  23700.         // New step necessary because of the 'chunking' method
  23701.         MDxFinalize( &mdDataSum );
  23702.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23703.     
  23704.     MDxInit( &mdDataSum );
  23705.     MD4Translate( lpData, len, &mdDataSum );    
  23706.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23707.  
  23708.     return;
  23709. }
  23710.  
  23711.  
  23712. -------------- Include
  23713.  
  23714. #ifndef __windows_h__
  23715.         typedef unsigned long DWORD;
  23716.         #define STDCALL _stdcall
  23717. #endif
  23718.  
  23719. typedef struct 
  23720. {
  23721.     DWORD dwSum[4];
  23722. }MDxSum;
  23723.  
  23724. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  23725. void STDCALL MDxInit( MDxSum * );
  23726. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  23727. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  23728. const char * STDCALL MDxGetVersion();
  23729. void STDCALL MDxFinalize( MDxSum * );
  23730.  
  23731.  
  23732.  
  23733. #include "mdx.h"
  23734. #include <stdlib.h>
  23735. #include <stdio.h>
  23736. #include <string.h>
  23737.  
  23738. // READLEN % 64 must = 0
  23739. #define READLEN    1048576L // 2^20, 1MB
  23740.  
  23741. void DigestFile( char * );
  23742. void DigestString();
  23743.  
  23744. void main(int argc, char *argv[])
  23745. {
  23746.     printf("%s\n\n", MDxGetVersion());
  23747.  
  23748.     if( argc > 1 )
  23749.         DigestFile( argv[1] );
  23750.     else    
  23751.         DigestString();
  23752.  
  23753. }
  23754.  
  23755. /*
  23756.     I use the 'chunk' method for processing files not because of
  23757.     limitations of my dll, but think what would happen if you
  23758.     tried to load an entire cd image into memory.
  23759. */
  23760. void DigestFile( char *szFName )
  23761. {
  23762.     FILE *file;
  23763.     void *lpData;
  23764.     long flen, mlen;
  23765.     MDxSum mdDataSum;
  23766.     MDxSum md4DataSum;
  23767.  
  23768.     // the 64 is for padding purposes
  23769.     lpData = malloc( READLEN + 64 );
  23770.     
  23771.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23772.  
  23773.     file = fopen( szFName, "rb" );
  23774.     if( file == NULL )
  23775.     {
  23776.         printf("ERROR: File not found.\n");
  23777.         return;
  23778.     }
  23779.     
  23780.     MDxInit( &mdDataSum );
  23781.     MDxInit( &md4DataSum );
  23782.     
  23783.     fseek( file, 0, SEEK_END );
  23784.     //Get the file length
  23785.     flen = mlen = ftell( file );
  23786.     fseek( file, 0, SEEK_SET );
  23787.     
  23788.     // When it takes a while to process a large file,
  23789.     // remember that for each chunk it has to run 
  23790.     // through the main translation loop 16384 times!
  23791.         
  23792.     printf("Processing %ld byte file: .", flen );
  23793.     
  23794.     while( flen > READLEN )
  23795.     {
  23796.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23797.         {
  23798.             printf("READ ERROR!\n");
  23799.             return;
  23800.         }
  23801.         MD5Translate( lpData, READLEN, &mdDataSum );
  23802.         MD4Translate( lpData, READLEN, &md4DataSum );
  23803.         flen -= READLEN;
  23804.         printf(".");
  23805.     }
  23806.  
  23807.     if (fread( lpData, 1, flen, file ) != flen)
  23808.     {
  23809.         printf("READ ERROR!\n");
  23810.         return;
  23811.     }
  23812.     // This is why I added the new argument to MDxPad
  23813.     // So we can pass the length of the data AND the
  23814.     // Total length of the message
  23815.     // Also it now returns the # of padding bytes added,
  23816.     // this is for files that are an exact multiple of the chunk
  23817.     // length. (Otherwise the padding isn't Translated)
  23818.     flen += MDxPad( lpData, flen, mlen );
  23819.     MD5Translate( lpData, flen, &mdDataSum );    
  23820.     MD4Translate( lpData, flen, &md4DataSum );
  23821.  
  23822.     // New step necessary because of the 'chunking' method
  23823.     MDxFinalize( &mdDataSum );
  23824.     MDxFinalize( &md4DataSum );
  23825.     
  23826.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23827.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23828.     fclose(file);
  23829.         
  23830. }
  23831.  
  23832. void DigestString()
  23833. {
  23834.     
  23835.     //For our demo purposes, no strings bigger than 1024 :)
  23836.     unsigned char lpData[1024] = "";
  23837.     long len = 0;
  23838.     MDxSum mdDataSum;
  23839.  
  23840.     printf("Enter the string to digest: ");
  23841.     scanf("%s", &lpData );
  23842.     len = strlen(lpData);
  23843.     
  23844.     // Have to do this before the Padding...well...it's best anyway;)
  23845.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23846.     
  23847.     // For the strings, we're gonna pad and digest the string
  23848.     // in one pass.
  23849.     MDxInit( &mdDataSum );
  23850.     MDxPad( lpData, len, len );
  23851.     
  23852.     MD5Translate( lpData, len, &mdDataSum );
  23853.         // New step necessary because of the 'chunking' method
  23854.         MDxFinalize( &mdDataSum );
  23855.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23856.     
  23857.     MDxInit( &mdDataSum );
  23858.     MD4Translate( lpData, len, &mdDataSum );    
  23859.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23860.  
  23861.     return;
  23862. }
  23863.  
  23864.  
  23865. -------------- Include
  23866.  
  23867. #ifndef __windows_h__
  23868.         typedef unsigned long DWORD;
  23869.         #define STDCALL _stdcall
  23870. #endif
  23871.  
  23872. typedef struct 
  23873. {
  23874.     DWORD dwSum[4];
  23875. }MDxSum;
  23876.  
  23877. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  23878. void STDCALL MDxInit( MDxSum * );
  23879. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  23880. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  23881. const char * STDCALL MDxGetVersion();
  23882. void STDCALL MDxFinalize( MDxSum * );
  23883.  
  23884.  
  23885. #include "mdx.h"
  23886. #include <stdlib.h>
  23887. #include <stdio.h>
  23888. #include <string.h>
  23889.  
  23890. // READLEN % 64 must = 0
  23891. #define READLEN    1048576L // 2^20, 1MB
  23892.  
  23893. void DigestFile( char * );
  23894. void DigestString();
  23895.  
  23896. void main(int argc, char *argv[])
  23897. {
  23898.     printf("%s\n\n", MDxGetVersion());
  23899.  
  23900.     if( argc > 1 )
  23901.         DigestFile( argv[1] );
  23902.     else    
  23903.         DigestString();
  23904.  
  23905. }
  23906.  
  23907. /*
  23908.     I use the 'chunk' method for processing files not because of
  23909.     limitations of my dll, but think what would happen if you
  23910.     tried to load an entire cd image into memory.
  23911. */
  23912. void DigestFile( char *szFName )
  23913. {
  23914.     FILE *file;
  23915.     void *lpData;
  23916.     long flen, mlen;
  23917.     MDxSum mdDataSum;
  23918.     MDxSum md4DataSum;
  23919.  
  23920.     // the 64 is for padding purposes
  23921.     lpData = malloc( READLEN + 64 );
  23922.     
  23923.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  23924.  
  23925.     file = fopen( szFName, "rb" );
  23926.     if( file == NULL )
  23927.     {
  23928.         printf("ERROR: File not found.\n");
  23929.         return;
  23930.     }
  23931.     
  23932.     MDxInit( &mdDataSum );
  23933.     MDxInit( &md4DataSum );
  23934.     
  23935.     fseek( file, 0, SEEK_END );
  23936.     //Get the file length
  23937.     flen = mlen = ftell( file );
  23938.     fseek( file, 0, SEEK_SET );
  23939.     
  23940.     // When it takes a while to process a large file,
  23941.     // remember that for each chunk it has to run 
  23942.     // through the main translation loop 16384 times!
  23943.         
  23944.     printf("Processing %ld byte file: .", flen );
  23945.     
  23946.     while( flen > READLEN )
  23947.     {
  23948.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  23949.         {
  23950.             printf("READ ERROR!\n");
  23951.             return;
  23952.         }
  23953.         MD5Translate( lpData, READLEN, &mdDataSum );
  23954.         MD4Translate( lpData, READLEN, &md4DataSum );
  23955.         flen -= READLEN;
  23956.         printf(".");
  23957.     }
  23958.  
  23959.     if (fread( lpData, 1, flen, file ) != flen)
  23960.     {
  23961.         printf("READ ERROR!\n");
  23962.         return;
  23963.     }
  23964.     // This is why I added the new argument to MDxPad
  23965.     // So we can pass the length of the data AND the
  23966.     // Total length of the message
  23967.     // Also it now returns the # of padding bytes added,
  23968.     // this is for files that are an exact multiple of the chunk
  23969.     // length. (Otherwise the padding isn't Translated)
  23970.     flen += MDxPad( lpData, flen, mlen );
  23971.     MD5Translate( lpData, flen, &mdDataSum );    
  23972.     MD4Translate( lpData, flen, &md4DataSum );
  23973.  
  23974.     // New step necessary because of the 'chunking' method
  23975.     MDxFinalize( &mdDataSum );
  23976.     MDxFinalize( &md4DataSum );
  23977.     
  23978.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  23979.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  23980.     fclose(file);
  23981.         
  23982. }
  23983.  
  23984. void DigestString()
  23985. {
  23986.     
  23987.     //For our demo purposes, no strings bigger than 1024 :)
  23988.     unsigned char lpData[1024] = "";
  23989.     long len = 0;
  23990.     MDxSum mdDataSum;
  23991.  
  23992.     printf("Enter the string to digest: ");
  23993.     scanf("%s", &lpData );
  23994.     len = strlen(lpData);
  23995.     
  23996.     // Have to do this before the Padding...well...it's best anyway;)
  23997.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  23998.     
  23999.     // For the strings, we're gonna pad and digest the string
  24000.     // in one pass.
  24001.     MDxInit( &mdDataSum );
  24002.     MDxPad( lpData, len, len );
  24003.     
  24004.     MD5Translate( lpData, len, &mdDataSum );
  24005.         // New step necessary because of the 'chunking' method
  24006.         MDxFinalize( &mdDataSum );
  24007.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24008.     
  24009.     MDxInit( &mdDataSum );
  24010.     MD4Translate( lpData, len, &mdDataSum );    
  24011.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24012.  
  24013.     return;
  24014. }
  24015.  
  24016.  
  24017. -------------- Include
  24018.  
  24019. #ifndef __windows_h__
  24020.         typedef unsigned long DWORD;
  24021.         #define STDCALL _stdcall
  24022. #endif
  24023.  
  24024. typedef struct 
  24025. {
  24026.     DWORD dwSum[4];
  24027. }MDxSum;
  24028.  
  24029. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24030. void STDCALL MDxInit( MDxSum * );
  24031. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24032. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24033. const char * STDCALL MDxGetVersion();
  24034. void STDCALL MDxFinalize( MDxSum * );
  24035.  
  24036.  
  24037.  
  24038. #include "mdx.h"
  24039. #include <stdlib.h>
  24040. #include <stdio.h>
  24041. #include <string.h>
  24042.  
  24043. // READLEN % 64 must = 0
  24044. #define READLEN    1048576L // 2^20, 1MB
  24045.  
  24046. void DigestFile( char * );
  24047. void DigestString();
  24048.  
  24049. void main(int argc, char *argv[])
  24050. {
  24051.     printf("%s\n\n", MDxGetVersion());
  24052.  
  24053.     if( argc > 1 )
  24054.         DigestFile( argv[1] );
  24055.     else    
  24056.         DigestString();
  24057.  
  24058. }
  24059.  
  24060. /*
  24061.     I use the 'chunk' method for processing files not because of
  24062.     limitations of my dll, but think what would happen if you
  24063.     tried to load an entire cd image into memory.
  24064. */
  24065. void DigestFile( char *szFName )
  24066. {
  24067.     FILE *file;
  24068.     void *lpData;
  24069.     long flen, mlen;
  24070.     MDxSum mdDataSum;
  24071.     MDxSum md4DataSum;
  24072.  
  24073.     // the 64 is for padding purposes
  24074.     lpData = malloc( READLEN + 64 );
  24075.     
  24076.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24077.  
  24078.     file = fopen( szFName, "rb" );
  24079.     if( file == NULL )
  24080.     {
  24081.         printf("ERROR: File not found.\n");
  24082.         return;
  24083.     }
  24084.     
  24085.     MDxInit( &mdDataSum );
  24086.     MDxInit( &md4DataSum );
  24087.     
  24088.     fseek( file, 0, SEEK_END );
  24089.     //Get the file length
  24090.     flen = mlen = ftell( file );
  24091.     fseek( file, 0, SEEK_SET );
  24092.     
  24093.     // When it takes a while to process a large file,
  24094.     // remember that for each chunk it has to run 
  24095.     // through the main translation loop 16384 times!
  24096.         
  24097.     printf("Processing %ld byte file: .", flen );
  24098.     
  24099.     while( flen > READLEN )
  24100.     {
  24101.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  24102.         {
  24103.             printf("READ ERROR!\n");
  24104.             return;
  24105.         }
  24106.         MD5Translate( lpData, READLEN, &mdDataSum );
  24107.         MD4Translate( lpData, READLEN, &md4DataSum );
  24108.         flen -= READLEN;
  24109.         printf(".");
  24110.     }
  24111.  
  24112.     if (fread( lpData, 1, flen, file ) != flen)
  24113.     {
  24114.         printf("READ ERROR!\n");
  24115.         return;
  24116.     }
  24117.     // This is why I added the new argument to MDxPad
  24118.     // So we can pass the length of the data AND the
  24119.     // Total length of the message
  24120.     // Also it now returns the # of padding bytes added,
  24121.     // this is for files that are an exact multiple of the chunk
  24122.     // length. (Otherwise the padding isn't Translated)
  24123.     flen += MDxPad( lpData, flen, mlen );
  24124.     MD5Translate( lpData, flen, &mdDataSum );    
  24125.     MD4Translate( lpData, flen, &md4DataSum );
  24126.  
  24127.     // New step necessary because of the 'chunking' method
  24128.     MDxFinalize( &mdDataSum );
  24129.     MDxFinalize( &md4DataSum );
  24130.     
  24131.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  24132.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24133.     fclose(file);
  24134.         
  24135. }
  24136.  
  24137. void DigestString()
  24138. {
  24139.     
  24140.     //For our demo purposes, no strings bigger than 1024 :)
  24141.     unsigned char lpData[1024] = "";
  24142.     long len = 0;
  24143.     MDxSum mdDataSum;
  24144.  
  24145.     printf("Enter the string to digest: ");
  24146.     scanf("%s", &lpData );
  24147.     len = strlen(lpData);
  24148.     
  24149.     // Have to do this before the Padding...well...it's best anyway;)
  24150.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  24151.     
  24152.     // For the strings, we're gonna pad and digest the string
  24153.     // in one pass.
  24154.     MDxInit( &mdDataSum );
  24155.     MDxPad( lpData, len, len );
  24156.     
  24157.     MD5Translate( lpData, len, &mdDataSum );
  24158.         // New step necessary because of the 'chunking' method
  24159.         MDxFinalize( &mdDataSum );
  24160.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24161.     
  24162.     MDxInit( &mdDataSum );
  24163.     MD4Translate( lpData, len, &mdDataSum );    
  24164.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24165.  
  24166.     return;
  24167. }
  24168.  
  24169.  
  24170. -------------- Include
  24171.  
  24172. #ifndef __windows_h__
  24173.         typedef unsigned long DWORD;
  24174.         #define STDCALL _stdcall
  24175. #endif
  24176.  
  24177. typedef struct 
  24178. {
  24179.     DWORD dwSum[4];
  24180. }MDxSum;
  24181.  
  24182. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24183. void STDCALL MDxInit( MDxSum * );
  24184. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24185. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24186. const char * STDCALL MDxGetVersion();
  24187. void STDCALL MDxFinalize( MDxSum * );
  24188.  
  24189.  
  24190.  
  24191. #include "mdx.h"
  24192. #include <stdlib.h>
  24193. #include <stdio.h>
  24194. #include <string.h>
  24195.  
  24196. // READLEN % 64 must = 0
  24197. #define READLEN    1048576L // 2^20, 1MB
  24198.  
  24199. void DigestFile( char * );
  24200. void DigestString();
  24201.  
  24202. void main(int argc, char *argv[])
  24203. {
  24204.     printf("%s\n\n", MDxGetVersion());
  24205.  
  24206.     if( argc > 1 )
  24207.         DigestFile( argv[1] );
  24208.     else    
  24209.         DigestString();
  24210.  
  24211. }
  24212.  
  24213. /*
  24214.     I use the 'chunk' method for processing files not because of
  24215.     limitations of my dll, but think what would happen if you
  24216.     tried to load an entire cd image into memory.
  24217. */
  24218. void DigestFile( char *szFName )
  24219. {
  24220.     FILE *file;
  24221.     void *lpData;
  24222.     long flen, mlen;
  24223.     MDxSum mdDataSum;
  24224.     MDxSum md4DataSum;
  24225.  
  24226.     // the 64 is for padding purposes
  24227.     lpData = malloc( READLEN + 64 );
  24228.     
  24229.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24230.  
  24231.     file = fopen( szFName, "rb" );
  24232.     if( file == NULL )
  24233.     {
  24234.         printf("ERROR: File not found.\n");
  24235.         return;
  24236.     }
  24237.     
  24238.     MDxInit( &mdDataSum );
  24239.     MDxInit( &md4DataSum );
  24240.     
  24241.     fseek( file, 0, SEEK_END );
  24242.     //Get the file length
  24243.     flen = mlen = ftell( file );
  24244.     fseek( file, 0, SEEK_SET );
  24245.     
  24246.     // When it takes a while to process a large file,
  24247.     // remember that for each chunk it has to run 
  24248.     // through the main translation loop 16384 times!
  24249.         
  24250.     printf("Processing %ld byte file: .", flen );
  24251.     
  24252.     while( flen > READLEN )
  24253.     {
  24254.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  24255.         {
  24256.             printf("READ ERROR!\n");
  24257.             return;
  24258.         }
  24259.         MD5Translate( lpData, READLEN, &mdDataSum );
  24260.         MD4Translate( lpData, READLEN, &md4DataSum );
  24261.         flen -= READLEN;
  24262.         printf(".");
  24263.     }
  24264.  
  24265.     if (fread( lpData, 1, flen, file ) != flen)
  24266.     {
  24267.         printf("READ ERROR!\n");
  24268.         return;
  24269.     }
  24270.     // This is why I added the new argument to MDxPad
  24271.     // So we can pass the length of the data AND the
  24272.     // Total length of the message
  24273.     // Also it now returns the # of padding bytes added,
  24274.     // this is for files that are an exact multiple of the chunk
  24275.     // length. (Otherwise the padding isn't Translated)
  24276.     flen += MDxPad( lpData, flen, mlen );
  24277.     MD5Translate( lpData, flen, &mdDataSum );    
  24278.     MD4Translate( lpData, flen, &md4DataSum );
  24279.  
  24280.     // New step necessary because of the 'chunking' method
  24281.     MDxFinalize( &mdDataSum );
  24282.     MDxFinalize( &md4DataSum );
  24283.     
  24284.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  24285.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24286.     fclose(file);
  24287.         
  24288. }
  24289.  
  24290. void DigestString()
  24291. {
  24292.     
  24293.     //For our demo purposes, no strings bigger than 1024 :)
  24294.     unsigned char lpData[1024] = "";
  24295.     long len = 0;
  24296.     MDxSum mdDataSum;
  24297.  
  24298.     printf("Enter the string to digest: ");
  24299.     scanf("%s", &lpData );
  24300.     len = strlen(lpData);
  24301.     
  24302.     // Have to do this before the Padding...well...it's best anyway;)
  24303.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  24304.     
  24305.     // For the strings, we're gonna pad and digest the string
  24306.     // in one pass.
  24307.     MDxInit( &mdDataSum );
  24308.     MDxPad( lpData, len, len );
  24309.     
  24310.     MD5Translate( lpData, len, &mdDataSum );
  24311.         // New step necessary because of the 'chunking' method
  24312.         MDxFinalize( &mdDataSum );
  24313.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24314.     
  24315.     MDxInit( &mdDataSum );
  24316.     MD4Translate( lpData, len, &mdDataSum );    
  24317.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24318.  
  24319.     return;
  24320. }
  24321.  
  24322.  
  24323. -------------- Include
  24324.  
  24325. #ifndef __windows_h__
  24326.         typedef unsigned long DWORD;
  24327.         #define STDCALL _stdcall
  24328. #endif
  24329.  
  24330. typedef struct 
  24331. {
  24332.     DWORD dwSum[4];
  24333. }MDxSum;
  24334.  
  24335. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24336. void STDCALL MDxInit( MDxSum * );
  24337. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24338. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24339. const char * STDCALL MDxGetVersion();
  24340. void STDCALL MDxFinalize( MDxSum * );
  24341.  
  24342.  
  24343. #include "mdx.h"
  24344. #include <stdlib.h>
  24345. #include <stdio.h>
  24346. #include <string.h>
  24347.  
  24348. // READLEN % 64 must = 0
  24349. #define READLEN    1048576L // 2^20, 1MB
  24350.  
  24351. void DigestFile( char * );
  24352. void DigestString();
  24353.  
  24354. void main(int argc, char *argv[])
  24355. {
  24356.     printf("%s\n\n", MDxGetVersion());
  24357.  
  24358.     if( argc > 1 )
  24359.         DigestFile( argv[1] );
  24360.     else    
  24361.         DigestString();
  24362.  
  24363. }
  24364.  
  24365. /*
  24366.     I use the 'chunk' method for processing files not because of
  24367.     limitations of my dll, but think what would happen if you
  24368.     tried to load an entire cd image into memory.
  24369. */
  24370. void DigestFile( char *szFName )
  24371. {
  24372.     FILE *file;
  24373.     void *lpData;
  24374.     long flen, mlen;
  24375.     MDxSum mdDataSum;
  24376.     MDxSum md4DataSum;
  24377.  
  24378.     // the 64 is for padding purposes
  24379.     lpData = malloc( READLEN + 64 );
  24380.     
  24381.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24382.  
  24383.     file = fopen( szFName, "rb" );
  24384.     if( file == NULL )
  24385.     {
  24386.         printf("ERROR: File not found.\n");
  24387.         return;
  24388.     }
  24389.     
  24390.     MDxInit( &mdDataSum );
  24391.     MDxInit( &md4DataSum );
  24392.     
  24393.     fseek( file, 0, SEEK_END );
  24394.     //Get the file length
  24395.     flen = mlen = ftell( file );
  24396.     fseek( file, 0, SEEK_SET );
  24397.     
  24398.     // When it takes a while to process a large file,
  24399.     // remember that for each chunk it has to run 
  24400.     // through the main translation loop 16384 times!
  24401.         
  24402.     printf("Processing %ld byte file: .", flen );
  24403.     
  24404.     while( flen > READLEN )
  24405.     {
  24406.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  24407.         {
  24408.             printf("READ ERROR!\n");
  24409.             return;
  24410.         }
  24411.         MD5Translate( lpData, READLEN, &mdDataSum );
  24412.         MD4Translate( lpData, READLEN, &md4DataSum );
  24413.         flen -= READLEN;
  24414.         printf(".");
  24415.     }
  24416.  
  24417.     if (fread( lpData, 1, flen, file ) != flen)
  24418.     {
  24419.         printf("READ ERROR!\n");
  24420.         return;
  24421.     }
  24422.     // This is why I added the new argument to MDxPad
  24423.     // So we can pass the length of the data AND the
  24424.     // Total length of the message
  24425.     // Also it now returns the # of padding bytes added,
  24426.     // this is for files that are an exact multiple of the chunk
  24427.     // length. (Otherwise the padding isn't Translated)
  24428.     flen += MDxPad( lpData, flen, mlen );
  24429.     MD5Translate( lpData, flen, &mdDataSum );    
  24430.     MD4Translate( lpData, flen, &md4DataSum );
  24431.  
  24432.     // New step necessary because of the 'chunking' method
  24433.     MDxFinalize( &mdDataSum );
  24434.     MDxFinalize( &md4DataSum );
  24435.     
  24436.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  24437.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24438.     fclose(file);
  24439.         
  24440. }
  24441.  
  24442. void DigestString()
  24443. {
  24444.     
  24445.     //For our demo purposes, no strings bigger than 1024 :)
  24446.     unsigned char lpData[1024] = "";
  24447.     long len = 0;
  24448.     MDxSum mdDataSum;
  24449.  
  24450.     printf("Enter the string to digest: ");
  24451.     scanf("%s", &lpData );
  24452.     len = strlen(lpData);
  24453.     
  24454.     // Have to do this before the Padding...well...it's best anyway;)
  24455.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  24456.     
  24457.     // For the strings, we're gonna pad and digest the string
  24458.     // in one pass.
  24459.     MDxInit( &mdDataSum );
  24460.     MDxPad( lpData, len, len );
  24461.     
  24462.     MD5Translate( lpData, len, &mdDataSum );
  24463.         // New step necessary because of the 'chunking' method
  24464.         MDxFinalize( &mdDataSum );
  24465.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24466.     
  24467.     MDxInit( &mdDataSum );
  24468.     MD4Translate( lpData, len, &mdDataSum );    
  24469.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24470.  
  24471.     return;
  24472. }
  24473.  
  24474.  
  24475. -------------- Include
  24476.  
  24477. #ifndef __windows_h__
  24478.         typedef unsigned long DWORD;
  24479.         #define STDCALL _stdcall
  24480. #endif
  24481.  
  24482. typedef struct 
  24483. {
  24484.     DWORD dwSum[4];
  24485. }MDxSum;
  24486.  
  24487. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24488. void STDCALL MDxInit( MDxSum * );
  24489. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24490. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24491. const char * STDCALL MDxGetVersion();
  24492. void STDCALL MDxFinalize( MDxSum * );
  24493.  
  24494.  
  24495. #include "mdx.h"
  24496. #include <stdlib.h>
  24497. #include <stdio.h>
  24498. #include <string.h>
  24499.  
  24500. // READLEN % 64 must = 0
  24501. #define READLEN    1048576L // 2^20, 1MB
  24502.  
  24503. void DigestFile( char * );
  24504. void DigestString();
  24505.  
  24506. void main(int argc, char *argv[])
  24507. {
  24508.     printf("%s\n\n", MDxGetVersion());
  24509.  
  24510.     if( argc > 1 )
  24511.         DigestFile( argv[1] );
  24512.     else    
  24513.         DigestString();
  24514.  
  24515. }
  24516.  
  24517. /*
  24518.     I use the 'chunk' method for processing files not because of
  24519.     limitations of my dll, but think what would happen if you
  24520.     tried to load an entire cd image into memory.
  24521. */
  24522. void DigestFile( char *szFName )
  24523. {
  24524.     FILE *file;
  24525.     void *lpData;
  24526.     long flen, mlen;
  24527.     MDxSum mdDataSum;
  24528.     MDxSum md4DataSum;
  24529.  
  24530.     // the 64 is for padding purposes
  24531.     lpData = malloc( READLEN + 64 );
  24532.     
  24533.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24534.  
  24535.     file = fopen( szFName, "rb" );
  24536.     if( file == NULL )
  24537.     {
  24538.         printf("ERROR: File not found.\n");
  24539.         return;
  24540.     }
  24541.     
  24542.     MDxInit( &mdDataSum );
  24543.     MDxInit( &md4DataSum );
  24544.     
  24545.     fseek( file, 0, SEEK_END );
  24546.     //Get the file length
  24547.     flen = mlen = ftell( file );
  24548.     fseek( file, 0, SEEK_SET );
  24549.     
  24550.     // When it takes a while to process a large file,
  24551.     // remember that for each chunk it has to run 
  24552.     // through the main translation loop 16384 times!
  24553.         
  24554.     printf("Processing %ld byte file: .", flen );
  24555.     
  24556.     while( flen > READLEN )
  24557.     {
  24558.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  24559.         {
  24560.             printf("READ ERROR!\n");
  24561.             return;
  24562.         }
  24563.         MD5Translate( lpData, READLEN, &mdDataSum );
  24564.         MD4Translate( lpData, READLEN, &md4DataSum );
  24565.         flen -= READLEN;
  24566.         printf(".");
  24567.     }
  24568.  
  24569.     if (fread( lpData, 1, flen, file ) != flen)
  24570.     {
  24571.         printf("READ ERROR!\n");
  24572.         return;
  24573.     }
  24574.     // This is why I added the new argument to MDxPad
  24575.     // So we can pass the length of the data AND the
  24576.     // Total length of the message
  24577.     // Also it now returns the # of padding bytes added,
  24578.     // this is for files that are an exact multiple of the chunk
  24579.     // length. (Otherwise the padding isn't Translated)
  24580.     flen += MDxPad( lpData, flen, mlen );
  24581.     MD5Translate( lpData, flen, &mdDataSum );    
  24582.     MD4Translate( lpData, flen, &md4DataSum );
  24583.  
  24584.     // New step necessary because of the 'chunking' method
  24585.     MDxFinalize( &mdDataSum );
  24586.     MDxFinalize( &md4DataSum );
  24587.     
  24588.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  24589.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24590.     fclose(file);
  24591.         
  24592. }
  24593.  
  24594. void DigestString()
  24595. {
  24596.     
  24597.     //For our demo purposes, no strings bigger than 1024 :)
  24598.     unsigned char lpData[1024] = "";
  24599.     long len = 0;
  24600.     MDxSum mdDataSum;
  24601.  
  24602.     printf("Enter the string to digest: ");
  24603.     scanf("%s", &lpData );
  24604.     len = strlen(lpData);
  24605.     
  24606.     // Have to do this before the Padding...well...it's best anyway;)
  24607.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  24608.     
  24609.     // For the strings, we're gonna pad and digest the string
  24610.     // in one pass.
  24611.     MDxInit( &mdDataSum );
  24612.     MDxPad( lpData, len, len );
  24613.     
  24614.     MD5Translate( lpData, len, &mdDataSum );
  24615.         // New step necessary because of the 'chunking' method
  24616.         MDxFinalize( &mdDataSum );
  24617.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24618.     
  24619.     MDxInit( &mdDataSum );
  24620.     MD4Translate( lpData, len, &mdDataSum );    
  24621.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24622.  
  24623.     return;
  24624. }
  24625.  
  24626.  
  24627. -------------- Include
  24628.  
  24629. #ifndef __windows_h__
  24630.         typedef unsigned long DWORD;
  24631.         #define STDCALL _stdcall
  24632. #endif
  24633.  
  24634. typedef struct 
  24635. {
  24636.     DWORD dwSum[4];
  24637. }MDxSum;
  24638.  
  24639. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24640. void STDCALL MDxInit( MDxSum * );
  24641. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24642. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24643. const char * STDCALL MDxGetVersion();
  24644. void STDCALL MDxFinalize( MDxSum * );
  24645.  
  24646.  
  24647.  
  24648. #include "mdx.h"
  24649. #include <stdlib.h>
  24650. #include <stdio.h>
  24651. #include <string.h>
  24652.  
  24653. // READLEN % 64 must = 0
  24654. #define READLEN    1048576L // 2^20, 1MB
  24655.  
  24656. void DigestFile( char * );
  24657. void DigestString();
  24658.  
  24659. void main(int argc, char *argv[])
  24660. {
  24661.     printf("%s\n\n", MDxGetVersion());
  24662.  
  24663.     if( argc > 1 )
  24664.         DigestFile( argv[1] );
  24665.     else    
  24666.         DigestString();
  24667.  
  24668. }
  24669.  
  24670. /*
  24671.     I use the 'chunk' method for processing files not because of
  24672.     limitations of my dll, but think what would happen if you
  24673.     tried to load an entire cd image into memory.
  24674. */
  24675. void DigestFile( char *szFName )
  24676. {
  24677.     FILE *file;
  24678.     void *lpData;
  24679.     long flen, mlen;
  24680.     MDxSum mdDataSum;
  24681.     MDxSum md4DataSum;
  24682.  
  24683.     // the 64 is for padding purposes
  24684.     lpData = malloc( READLEN + 64 );
  24685.     
  24686.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24687.  
  24688.     file = fopen( szFName, "rb" );
  24689.     if( file == NULL )
  24690.     {
  24691.         printf("ERROR: File not found.\n");
  24692.         return;
  24693.     }
  24694.     
  24695.     MDxInit( &mdDataSum );
  24696.     MDxInit( &md4DataSum );
  24697.     
  24698.     fseek( file, 0, SEEK_END );
  24699.     //Get the file length
  24700.     flen = mlen = ftell( file );
  24701.     fseek( file, 0, SEEK_SET );
  24702.     
  24703.     // When it takes a while to process a large file,
  24704.     // remember that for each chunk it has to run 
  24705.     // through the main translation loop 16384 times!
  24706.         
  24707.     printf("Processing %ld byte file: .", flen );
  24708.     
  24709.     while( flen > READLEN )
  24710.     {
  24711.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  24712.         {
  24713.             printf("READ ERROR!\n");
  24714.             return;
  24715.         }
  24716.         MD5Translate( lpData, READLEN, &mdDataSum );
  24717.         MD4Translate( lpData, READLEN, &md4DataSum );
  24718.         flen -= READLEN;
  24719.         printf(".");
  24720.     }
  24721.  
  24722.     if (fread( lpData, 1, flen, file ) != flen)
  24723.     {
  24724.         printf("READ ERROR!\n");
  24725.         return;
  24726.     }
  24727.     // This is why I added the new argument to MDxPad
  24728.     // So we can pass the length of the data AND the
  24729.     // Total length of the message
  24730.     // Also it now returns the # of padding bytes added,
  24731.     // this is for files that are an exact multiple of the chunk
  24732.     // length. (Otherwise the padding isn't Translated)
  24733.     flen += MDxPad( lpData, flen, mlen );
  24734.     MD5Translate( lpData, flen, &mdDataSum );    
  24735.     MD4Translate( lpData, flen, &md4DataSum );
  24736.  
  24737.     // New step necessary because of the 'chunking' method
  24738.     MDxFinalize( &mdDataSum );
  24739.     MDxFinalize( &md4DataSum );
  24740.     
  24741.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  24742.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24743.     fclose(file);
  24744.         
  24745. }
  24746.  
  24747. void DigestString()
  24748. {
  24749.     
  24750.     //For our demo purposes, no strings bigger than 1024 :)
  24751.     unsigned char lpData[1024] = "";
  24752.     long len = 0;
  24753.     MDxSum mdDataSum;
  24754.  
  24755.     printf("Enter the string to digest: ");
  24756.     scanf("%s", &lpData );
  24757.     len = strlen(lpData);
  24758.     
  24759.     // Have to do this before the Padding...well...it's best anyway;)
  24760.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  24761.     
  24762.     // For the strings, we're gonna pad and digest the string
  24763.     // in one pass.
  24764.     MDxInit( &mdDataSum );
  24765.     MDxPad( lpData, len, len );
  24766.     
  24767.     MD5Translate( lpData, len, &mdDataSum );
  24768.         // New step necessary because of the 'chunking' method
  24769.         MDxFinalize( &mdDataSum );
  24770.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24771.     
  24772.     MDxInit( &mdDataSum );
  24773.     MD4Translate( lpData, len, &mdDataSum );    
  24774.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24775.  
  24776.     return;
  24777. }
  24778.  
  24779.  
  24780. -------------- Include
  24781.  
  24782. #ifndef __windows_h__
  24783.         typedef unsigned long DWORD;
  24784.         #define STDCALL _stdcall
  24785. #endif
  24786.  
  24787. typedef struct 
  24788. {
  24789.     DWORD dwSum[4];
  24790. }MDxSum;
  24791.  
  24792. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24793. void STDCALL MDxInit( MDxSum * );
  24794. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24795. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24796. const char * STDCALL MDxGetVersion();
  24797. void STDCALL MDxFinalize( MDxSum * );
  24798.  
  24799.  
  24800.  
  24801. #include "mdx.h"
  24802. #include <stdlib.h>
  24803. #include <stdio.h>
  24804. #include <string.h>
  24805.  
  24806. // READLEN % 64 must = 0
  24807. #define READLEN    1048576L // 2^20, 1MB
  24808.  
  24809. void DigestFile( char * );
  24810. void DigestString();
  24811.  
  24812. void main(int argc, char *argv[])
  24813. {
  24814.     printf("%s\n\n", MDxGetVersion());
  24815.  
  24816.     if( argc > 1 )
  24817.         DigestFile( argv[1] );
  24818.     else    
  24819.         DigestString();
  24820.  
  24821. }
  24822.  
  24823. /*
  24824.     I use the 'chunk' method for processing files not because of
  24825.     limitations of my dll, but think what would happen if you
  24826.     tried to load an entire cd image into memory.
  24827. */
  24828. void DigestFile( char *szFName )
  24829. {
  24830.     FILE *file;
  24831.     void *lpData;
  24832.     long flen, mlen;
  24833.     MDxSum mdDataSum;
  24834.     MDxSum md4DataSum;
  24835.  
  24836.     // the 64 is for padding purposes
  24837.     lpData = malloc( READLEN + 64 );
  24838.     
  24839.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24840.  
  24841.     file = fopen( szFName, "rb" );
  24842.     if( file == NULL )
  24843.     {
  24844.         printf("ERROR: File not found.\n");
  24845.         return;
  24846.     }
  24847.     
  24848.     MDxInit( &mdDataSum );
  24849.     MDxInit( &md4DataSum );
  24850.     
  24851.     fseek( file, 0, SEEK_END );
  24852.     //Get the file length
  24853.     flen = mlen = ftell( file );
  24854.     fseek( file, 0, SEEK_SET );
  24855.     
  24856.     // When it takes a while to process a large file,
  24857.     // remember that for each chunk it has to run 
  24858.     // through the main translation loop 16384 times!
  24859.         
  24860.     printf("Processing %ld byte file: .", flen );
  24861.     
  24862.     while( flen > READLEN )
  24863.     {
  24864.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  24865.         {
  24866.             printf("READ ERROR!\n");
  24867.             return;
  24868.         }
  24869.         MD5Translate( lpData, READLEN, &mdDataSum );
  24870.         MD4Translate( lpData, READLEN, &md4DataSum );
  24871.         flen -= READLEN;
  24872.         printf(".");
  24873.     }
  24874.  
  24875.     if (fread( lpData, 1, flen, file ) != flen)
  24876.     {
  24877.         printf("READ ERROR!\n");
  24878.         return;
  24879.     }
  24880.     // This is why I added the new argument to MDxPad
  24881.     // So we can pass the length of the data AND the
  24882.     // Total length of the message
  24883.     // Also it now returns the # of padding bytes added,
  24884.     // this is for files that are an exact multiple of the chunk
  24885.     // length. (Otherwise the padding isn't Translated)
  24886.     flen += MDxPad( lpData, flen, mlen );
  24887.     MD5Translate( lpData, flen, &mdDataSum );    
  24888.     MD4Translate( lpData, flen, &md4DataSum );
  24889.  
  24890.     // New step necessary because of the 'chunking' method
  24891.     MDxFinalize( &mdDataSum );
  24892.     MDxFinalize( &md4DataSum );
  24893.     
  24894.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  24895.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24896.     fclose(file);
  24897.         
  24898. }
  24899.  
  24900. void DigestString()
  24901. {
  24902.     
  24903.     //For our demo purposes, no strings bigger than 1024 :)
  24904.     unsigned char lpData[1024] = "";
  24905.     long len = 0;
  24906.     MDxSum mdDataSum;
  24907.  
  24908.     printf("Enter the string to digest: ");
  24909.     scanf("%s", &lpData );
  24910.     len = strlen(lpData);
  24911.     
  24912.     // Have to do this before the Padding...well...it's best anyway;)
  24913.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  24914.     
  24915.     // For the strings, we're gonna pad and digest the string
  24916.     // in one pass.
  24917.     MDxInit( &mdDataSum );
  24918.     MDxPad( lpData, len, len );
  24919.     
  24920.     MD5Translate( lpData, len, &mdDataSum );
  24921.         // New step necessary because of the 'chunking' method
  24922.         MDxFinalize( &mdDataSum );
  24923.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24924.     
  24925.     MDxInit( &mdDataSum );
  24926.     MD4Translate( lpData, len, &mdDataSum );    
  24927.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  24928.  
  24929.     return;
  24930. }
  24931.  
  24932.  
  24933. -------------- Include
  24934.  
  24935. #ifndef __windows_h__
  24936.         typedef unsigned long DWORD;
  24937.         #define STDCALL _stdcall
  24938. #endif
  24939.  
  24940. typedef struct 
  24941. {
  24942.     DWORD dwSum[4];
  24943. }MDxSum;
  24944.  
  24945. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  24946. void STDCALL MDxInit( MDxSum * );
  24947. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  24948. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  24949. const char * STDCALL MDxGetVersion();
  24950. void STDCALL MDxFinalize( MDxSum * );
  24951.  
  24952.  
  24953.  
  24954. #include "mdx.h"
  24955. #include <stdlib.h>
  24956. #include <stdio.h>
  24957. #include <string.h>
  24958.  
  24959. // READLEN % 64 must = 0
  24960. #define READLEN    1048576L // 2^20, 1MB
  24961.  
  24962. void DigestFile( char * );
  24963. void DigestString();
  24964.  
  24965. void main(int argc, char *argv[])
  24966. {
  24967.     printf("%s\n\n", MDxGetVersion());
  24968.  
  24969.     if( argc > 1 )
  24970.         DigestFile( argv[1] );
  24971.     else    
  24972.         DigestString();
  24973.  
  24974. }
  24975.  
  24976. /*
  24977.     I use the 'chunk' method for processing files not because of
  24978.     limitations of my dll, but think what would happen if you
  24979.     tried to load an entire cd image into memory.
  24980. */
  24981. void DigestFile( char *szFName )
  24982. {
  24983.     FILE *file;
  24984.     void *lpData;
  24985.     long flen, mlen;
  24986.     MDxSum mdDataSum;
  24987.     MDxSum md4DataSum;
  24988.  
  24989.     // the 64 is for padding purposes
  24990.     lpData = malloc( READLEN + 64 );
  24991.     
  24992.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  24993.  
  24994.     file = fopen( szFName, "rb" );
  24995.     if( file == NULL )
  24996.     {
  24997.         printf("ERROR: File not found.\n");
  24998.         return;
  24999.     }
  25000.     
  25001.     MDxInit( &mdDataSum );
  25002.     MDxInit( &md4DataSum );
  25003.     
  25004.     fseek( file, 0, SEEK_END );
  25005.     //Get the file length
  25006.     flen = mlen = ftell( file );
  25007.     fseek( file, 0, SEEK_SET );
  25008.     
  25009.     // When it takes a while to process a large file,
  25010.     // remember that for each chunk it has to run 
  25011.     // through the main translation loop 16384 times!
  25012.         
  25013.     printf("Processing %ld byte file: .", flen );
  25014.     
  25015.     while( flen > READLEN )
  25016.     {
  25017.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25018.         {
  25019.             printf("READ ERROR!\n");
  25020.             return;
  25021.         }
  25022.         MD5Translate( lpData, READLEN, &mdDataSum );
  25023.         MD4Translate( lpData, READLEN, &md4DataSum );
  25024.         flen -= READLEN;
  25025.         printf(".");
  25026.     }
  25027.  
  25028.     if (fread( lpData, 1, flen, file ) != flen)
  25029.     {
  25030.         printf("READ ERROR!\n");
  25031.         return;
  25032.     }
  25033.     // This is why I added the new argument to MDxPad
  25034.     // So we can pass the length of the data AND the
  25035.     // Total length of the message
  25036.     // Also it now returns the # of padding bytes added,
  25037.     // this is for files that are an exact multiple of the chunk
  25038.     // length. (Otherwise the padding isn't Translated)
  25039.     flen += MDxPad( lpData, flen, mlen );
  25040.     MD5Translate( lpData, flen, &mdDataSum );    
  25041.     MD4Translate( lpData, flen, &md4DataSum );
  25042.  
  25043.     // New step necessary because of the 'chunking' method
  25044.     MDxFinalize( &mdDataSum );
  25045.     MDxFinalize( &md4DataSum );
  25046.     
  25047.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25048.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25049.     fclose(file);
  25050.         
  25051. }
  25052.  
  25053. void DigestString()
  25054. {
  25055.     
  25056.     //For our demo purposes, no strings bigger than 1024 :)
  25057.     unsigned char lpData[1024] = "";
  25058.     long len = 0;
  25059.     MDxSum mdDataSum;
  25060.  
  25061.     printf("Enter the string to digest: ");
  25062.     scanf("%s", &lpData );
  25063.     len = strlen(lpData);
  25064.     
  25065.     // Have to do this before the Padding...well...it's best anyway;)
  25066.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25067.     
  25068.     // For the strings, we're gonna pad and digest the string
  25069.     // in one pass.
  25070.     MDxInit( &mdDataSum );
  25071.     MDxPad( lpData, len, len );
  25072.     
  25073.     MD5Translate( lpData, len, &mdDataSum );
  25074.         // New step necessary because of the 'chunking' method
  25075.         MDxFinalize( &mdDataSum );
  25076.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25077.     
  25078.     MDxInit( &mdDataSum );
  25079.     MD4Translate( lpData, len, &mdDataSum );    
  25080.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25081.  
  25082.     return;
  25083. }
  25084.  
  25085.  
  25086. -------------- Include
  25087.  
  25088. #ifndef __windows_h__
  25089.         typedef unsigned long DWORD;
  25090.         #define STDCALL _stdcall
  25091. #endif
  25092.  
  25093. typedef struct 
  25094. {
  25095.     DWORD dwSum[4];
  25096. }MDxSum;
  25097.  
  25098. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  25099. void STDCALL MDxInit( MDxSum * );
  25100. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  25101. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  25102. const char * STDCALL MDxGetVersion();
  25103. void STDCALL MDxFinalize( MDxSum * );
  25104.  
  25105.  
  25106.  
  25107. #include "mdx.h"
  25108. #include <stdlib.h>
  25109. #include <stdio.h>
  25110. #include <string.h>
  25111.  
  25112. // READLEN % 64 must = 0
  25113. #define READLEN    1048576L // 2^20, 1MB
  25114.  
  25115. void DigestFile( char * );
  25116. void DigestString();
  25117.  
  25118. void main(int argc, char *argv[])
  25119. {
  25120.     printf("%s\n\n", MDxGetVersion());
  25121.  
  25122.     if( argc > 1 )
  25123.         DigestFile( argv[1] );
  25124.     else    
  25125.         DigestString();
  25126.  
  25127. }
  25128.  
  25129. /*
  25130.     I use the 'chunk' method for processing files not because of
  25131.     limitations of my dll, but think what would happen if you
  25132.     tried to load an entire cd image into memory.
  25133. */
  25134. void DigestFile( char *szFName )
  25135. {
  25136.     FILE *file;
  25137.     void *lpData;
  25138.     long flen, mlen;
  25139.     MDxSum mdDataSum;
  25140.     MDxSum md4DataSum;
  25141.  
  25142.     // the 64 is for padding purposes
  25143.     lpData = malloc( READLEN + 64 );
  25144.     
  25145.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  25146.  
  25147.     file = fopen( szFName, "rb" );
  25148.     if( file == NULL )
  25149.     {
  25150.         printf("ERROR: File not found.\n");
  25151.         return;
  25152.     }
  25153.     
  25154.     MDxInit( &mdDataSum );
  25155.     MDxInit( &md4DataSum );
  25156.     
  25157.     fseek( file, 0, SEEK_END );
  25158.     //Get the file length
  25159.     flen = mlen = ftell( file );
  25160.     fseek( file, 0, SEEK_SET );
  25161.     
  25162.     // When it takes a while to process a large file,
  25163.     // remember that for each chunk it has to run 
  25164.     // through the main translation loop 16384 times!
  25165.         
  25166.     printf("Processing %ld byte file: .", flen );
  25167.     
  25168.     while( flen > READLEN )
  25169.     {
  25170.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25171.         {
  25172.             printf("READ ERROR!\n");
  25173.             return;
  25174.         }
  25175.         MD5Translate( lpData, READLEN, &mdDataSum );
  25176.         MD4Translate( lpData, READLEN, &md4DataSum );
  25177.         flen -= READLEN;
  25178.         printf(".");
  25179.     }
  25180.  
  25181.     if (fread( lpData, 1, flen, file ) != flen)
  25182.     {
  25183.         printf("READ ERROR!\n");
  25184.         return;
  25185.     }
  25186.     // This is why I added the new argument to MDxPad
  25187.     // So we can pass the length of the data AND the
  25188.     // Total length of the message
  25189.     // Also it now returns the # of padding bytes added,
  25190.     // this is for files that are an exact multiple of the chunk
  25191.     // length. (Otherwise the padding isn't Translated)
  25192.     flen += MDxPad( lpData, flen, mlen );
  25193.     MD5Translate( lpData, flen, &mdDataSum );    
  25194.     MD4Translate( lpData, flen, &md4DataSum );
  25195.  
  25196.     // New step necessary because of the 'chunking' method
  25197.     MDxFinalize( &mdDataSum );
  25198.     MDxFinalize( &md4DataSum );
  25199.     
  25200.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25201.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25202.     fclose(file);
  25203.         
  25204. }
  25205.  
  25206. void DigestString()
  25207. {
  25208.     
  25209.     //For our demo purposes, no strings bigger than 1024 :)
  25210.     unsigned char lpData[1024] = "";
  25211.     long len = 0;
  25212.     MDxSum mdDataSum;
  25213.  
  25214.     printf("Enter the string to digest: ");
  25215.     scanf("%s", &lpData );
  25216.     len = strlen(lpData);
  25217.     
  25218.     // Have to do this before the Padding...well...it's best anyway;)
  25219.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25220.     
  25221.     // For the strings, we're gonna pad and digest the string
  25222.     // in one pass.
  25223.     MDxInit( &mdDataSum );
  25224.     MDxPad( lpData, len, len );
  25225.     
  25226.     MD5Translate( lpData, len, &mdDataSum );
  25227.         // New step necessary because of the 'chunking' method
  25228.         MDxFinalize( &mdDataSum );
  25229.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25230.     
  25231.     MDxInit( &mdDataSum );
  25232.     MD4Translate( lpData, len, &mdDataSum );    
  25233.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25234.  
  25235.     return;
  25236. }
  25237.  
  25238.  
  25239. -------------- Include
  25240.  
  25241. #ifndef __windows_h__
  25242.         typedef unsigned long DWORD;
  25243.         #define STDCALL _stdcall
  25244. #endif
  25245.  
  25246. typedef struct 
  25247. {
  25248.     DWORD dwSum[4];
  25249. }MDxSum;
  25250.  
  25251. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  25252. void STDCALL MDxInit( MDxSum * );
  25253. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  25254. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  25255. const char * STDCALL MDxGetVersion();
  25256. void STDCALL MDxFinalize( MDxSum * );
  25257.  
  25258.  
  25259.  
  25260. #include "mdx.h"
  25261. #include <stdlib.h>
  25262. #include <stdio.h>
  25263. #include <string.h>
  25264.  
  25265. // READLEN % 64 must = 0
  25266. #define READLEN    1048576L // 2^20, 1MB
  25267.  
  25268. void DigestFile( char * );
  25269. void DigestString();
  25270.  
  25271. void main(int argc, char *argv[])
  25272. {
  25273.     printf("%s\n\n", MDxGetVersion());
  25274.  
  25275.     if( argc > 1 )
  25276.         DigestFile( argv[1] );
  25277.     else    
  25278.         DigestString();
  25279.  
  25280. }
  25281.  
  25282. /*
  25283.     I use the 'chunk' method for processing files not because of
  25284.     limitations of my dll, but think what would happen if you
  25285.     tried to load an entire cd image into memory.
  25286. */
  25287. void DigestFile( char *szFName )
  25288. {
  25289.     FILE *file;
  25290.     void *lpData;
  25291.     long flen, mlen;
  25292.     MDxSum mdDataSum;
  25293.     MDxSum md4DataSum;
  25294.  
  25295.     // the 64 is for padding purposes
  25296.     lpData = malloc( READLEN + 64 );
  25297.     
  25298.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  25299.  
  25300.     file = fopen( szFName, "rb" );
  25301.     if( file == NULL )
  25302.     {
  25303.         printf("ERROR: File not found.\n");
  25304.         return;
  25305.     }
  25306.     
  25307.     MDxInit( &mdDataSum );
  25308.     MDxInit( &md4DataSum );
  25309.     
  25310.     fseek( file, 0, SEEK_END );
  25311.     //Get the file length
  25312.     flen = mlen = ftell( file );
  25313.     fseek( file, 0, SEEK_SET );
  25314.     
  25315.     // When it takes a while to process a large file,
  25316.     // remember that for each chunk it has to run 
  25317.     // through the main translation loop 16384 times!
  25318.         
  25319.     printf("Processing %ld byte file: .", flen );
  25320.     
  25321.     while( flen > READLEN )
  25322.     {
  25323.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25324.         {
  25325.             printf("READ ERROR!\n");
  25326.             return;
  25327.         }
  25328.         MD5Translate( lpData, READLEN, &mdDataSum );
  25329.         MD4Translate( lpData, READLEN, &md4DataSum );
  25330.         flen -= READLEN;
  25331.         printf(".");
  25332.     }
  25333.  
  25334.     if (fread( lpData, 1, flen, file ) != flen)
  25335.     {
  25336.         printf("READ ERROR!\n");
  25337.         return;
  25338.     }
  25339.     // This is why I added the new argument to MDxPad
  25340.     // So we can pass the length of the data AND the
  25341.     // Total length of the message
  25342.     // Also it now returns the # of padding bytes added,
  25343.     // this is for files that are an exact multiple of the chunk
  25344.     // length. (Otherwise the padding isn't Translated)
  25345.     flen += MDxPad( lpData, flen, mlen );
  25346.     MD5Translate( lpData, flen, &mdDataSum );    
  25347.     MD4Translate( lpData, flen, &md4DataSum );
  25348.  
  25349.     // New step necessary because of the 'chunking' method
  25350.     MDxFinalize( &mdDataSum );
  25351.     MDxFinalize( &md4DataSum );
  25352.     
  25353.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25354.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25355.     fclose(file);
  25356.         
  25357. }
  25358.  
  25359. void DigestString()
  25360. {
  25361.     
  25362.     //For our demo purposes, no strings bigger than 1024 :)
  25363.     unsigned char lpData[1024] = "";
  25364.     long len = 0;
  25365.     MDxSum mdDataSum;
  25366.  
  25367.     printf("Enter the string to digest: ");
  25368.     scanf("%s", &lpData );
  25369.     len = strlen(lpData);
  25370.     
  25371.     // Have to do this before the Padding...well...it's best anyway;)
  25372.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25373.     
  25374.     // For the strings, we're gonna pad and digest the string
  25375.     // in one pass.
  25376.     MDxInit( &mdDataSum );
  25377.     MDxPad( lpData, len, len );
  25378.     
  25379.     MD5Translate( lpData, len, &mdDataSum );
  25380.         // New step necessary because of the 'chunking' method
  25381.         MDxFinalize( &mdDataSum );
  25382.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25383.     
  25384.     MDxInit( &mdDataSum );
  25385.     MD4Translate( lpData, len, &mdDataSum );    
  25386.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25387.  
  25388.     return;
  25389. }
  25390.  
  25391.  
  25392. -------------- Include
  25393.  
  25394. #ifndef __windows_h__
  25395.         typedef unsigned long DWORD;
  25396.         #define STDCALL _stdcall
  25397. #endif
  25398.  
  25399. typedef struct 
  25400. {
  25401.     DWORD dwSum[4];
  25402. }MDxSum;
  25403.  
  25404. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  25405. void STDCALL MDxInit( MDxSum * );
  25406. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  25407. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  25408. const char * STDCALL MDxGetVersion();
  25409. void STDCALL MDxFinalize( MDxSum * );
  25410.  
  25411.  
  25412.  
  25413. #include "mdx.h"
  25414. #include <stdlib.h>
  25415. #include <stdio.h>
  25416. #include <string.h>
  25417.  
  25418. // READLEN % 64 must = 0
  25419. #define READLEN    1048576L // 2^20, 1MB
  25420.  
  25421. void DigestFile( char * );
  25422. void DigestString();
  25423.  
  25424. void main(int argc, char *argv[])
  25425. {
  25426.     printf("%s\n\n", MDxGetVersion());
  25427.  
  25428.     if( argc > 1 )
  25429.         DigestFile( argv[1] );
  25430.     else    
  25431.         DigestString();
  25432.  
  25433. }
  25434.  
  25435. /*
  25436.     I use the 'chunk' method for processing files not because of
  25437.     limitations of my dll, but think what would happen if you
  25438.     tried to load an entire cd image into memory.
  25439. */
  25440. void DigestFile( char *szFName )
  25441. {
  25442.     FILE *file;
  25443.     void *lpData;
  25444.     long flen, mlen;
  25445.     MDxSum mdDataSum;
  25446.     MDxSum md4DataSum;
  25447.  
  25448.     // the 64 is for padding purposes
  25449.     lpData = malloc( READLEN + 64 );
  25450.     
  25451.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  25452.  
  25453.     file = fopen( szFName, "rb" );
  25454.     if( file == NULL )
  25455.     {
  25456.         printf("ERROR: File not found.\n");
  25457.         return;
  25458.     }
  25459.     
  25460.     MDxInit( &mdDataSum );
  25461.     MDxInit( &md4DataSum );
  25462.     
  25463.     fseek( file, 0, SEEK_END );
  25464.     //Get the file length
  25465.     flen = mlen = ftell( file );
  25466.     fseek( file, 0, SEEK_SET );
  25467.     
  25468.     // When it takes a while to process a large file,
  25469.     // remember that for each chunk it has to run 
  25470.     // through the main translation loop 16384 times!
  25471.         
  25472.     printf("Processing %ld byte file: .", flen );
  25473.     
  25474.     while( flen > READLEN )
  25475.     {
  25476.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25477.         {
  25478.             printf("READ ERROR!\n");
  25479.             return;
  25480.         }
  25481.         MD5Translate( lpData, READLEN, &mdDataSum );
  25482.         MD4Translate( lpData, READLEN, &md4DataSum );
  25483.         flen -= READLEN;
  25484.         printf(".");
  25485.     }
  25486.  
  25487.     if (fread( lpData, 1, flen, file ) != flen)
  25488.     {
  25489.         printf("READ ERROR!\n");
  25490.         return;
  25491.     }
  25492.     // This is why I added the new argument to MDxPad
  25493.     // So we can pass the length of the data AND the
  25494.     // Total length of the message
  25495.     // Also it now returns the # of padding bytes added,
  25496.     // this is for files that are an exact multiple of the chunk
  25497.     // length. (Otherwise the padding isn't Translated)
  25498.     flen += MDxPad( lpData, flen, mlen );
  25499.     MD5Translate( lpData, flen, &mdDataSum );    
  25500.     MD4Translate( lpData, flen, &md4DataSum );
  25501.  
  25502.     // New step necessary because of the 'chunking' method
  25503.     MDxFinalize( &mdDataSum );
  25504.     MDxFinalize( &md4DataSum );
  25505.     
  25506.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25507.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25508.     fclose(file);
  25509.         
  25510. }
  25511.  
  25512. void DigestString()
  25513. {
  25514.     
  25515.     //For our demo purposes, no strings bigger than 1024 :)
  25516.     unsigned char lpData[1024] = "";
  25517.     long len = 0;
  25518.     MDxSum mdDataSum;
  25519.  
  25520.     printf("Enter the string to digest: ");
  25521.     scanf("%s", &lpData );
  25522.     len = strlen(lpData);
  25523.     
  25524.     // Have to do this before the Padding...well...it's best anyway;)
  25525.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25526.     
  25527.     // For the strings, we're gonna pad and digest the string
  25528.     // in one pass.
  25529.     MDxInit( &mdDataSum );
  25530.     MDxPad( lpData, len, len );
  25531.     
  25532.     MD5Translate( lpData, len, &mdDataSum );
  25533.         // New step necessary because of the 'chunking' method
  25534.         MDxFinalize( &mdDataSum );
  25535.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25536.     
  25537.     MDxInit( &mdDataSum );
  25538.     MD4Translate( lpData, len, &mdDataSum );    
  25539.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25540.  
  25541.     return;
  25542. }
  25543.  
  25544.  
  25545. -------------- Include
  25546.  
  25547. #ifndef __windows_h__
  25548.         typedef unsigned long DWORD;
  25549.         #define STDCALL _stdcall
  25550. #endif
  25551.  
  25552. typedef struct 
  25553. {
  25554.     DWORD dwSum[4];
  25555. }MDxSum;
  25556.  
  25557. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  25558. void STDCALL MDxInit( MDxSum * );
  25559. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  25560. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  25561. const char * STDCALL MDxGetVersion();
  25562. void STDCALL MDxFinalize( MDxSum * );
  25563.  
  25564.  
  25565.  
  25566. #include "mdx.h"
  25567. #include <stdlib.h>
  25568. #include <stdio.h>
  25569. #include <string.h>
  25570.  
  25571. // READLEN % 64 must = 0
  25572. #define READLEN    1048576L // 2^20, 1MB
  25573.  
  25574. void DigestFile( char * );
  25575. void DigestString();
  25576.  
  25577. void main(int argc, char *argv[])
  25578. {
  25579.     printf("%s\n\n", MDxGetVersion());
  25580.  
  25581.     if( argc > 1 )
  25582.         DigestFile( argv[1] );
  25583.     else    
  25584.         DigestString();
  25585.  
  25586. }
  25587.  
  25588. /*
  25589.     I use the 'chunk' method for processing files not because of
  25590.     limitations of my dll, but think what would happen if you
  25591.     tried to load an entire cd image into memory.
  25592. */
  25593. void DigestFile( char *szFName )
  25594. {
  25595.     FILE *file;
  25596.     void *lpData;
  25597.     long flen, mlen;
  25598.     MDxSum mdDataSum;
  25599.     MDxSum md4DataSum;
  25600.  
  25601.     // the 64 is for padding purposes
  25602.     lpData = malloc( READLEN + 64 );
  25603.     
  25604.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  25605.  
  25606.     file = fopen( szFName, "rb" );
  25607.     if( file == NULL )
  25608.     {
  25609.         printf("ERROR: File not found.\n");
  25610.         return;
  25611.     }
  25612.     
  25613.     MDxInit( &mdDataSum );
  25614.     MDxInit( &md4DataSum );
  25615.     
  25616.     fseek( file, 0, SEEK_END );
  25617.     //Get the file length
  25618.     flen = mlen = ftell( file );
  25619.     fseek( file, 0, SEEK_SET );
  25620.     
  25621.     // When it takes a while to process a large file,
  25622.     // remember that for each chunk it has to run 
  25623.     // through the main translation loop 16384 times!
  25624.         
  25625.     printf("Processing %ld byte file: .", flen );
  25626.     
  25627.     while( flen > READLEN )
  25628.     {
  25629.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25630.         {
  25631.             printf("READ ERROR!\n");
  25632.             return;
  25633.         }
  25634.         MD5Translate( lpData, READLEN, &mdDataSum );
  25635.         MD4Translate( lpData, READLEN, &md4DataSum );
  25636.         flen -= READLEN;
  25637.         printf(".");
  25638.     }
  25639.  
  25640.     if (fread( lpData, 1, flen, file ) != flen)
  25641.     {
  25642.         printf("READ ERROR!\n");
  25643.         return;
  25644.     }
  25645.     // This is why I added the new argument to MDxPad
  25646.     // So we can pass the length of the data AND the
  25647.     // Total length of the message
  25648.     // Also it now returns the # of padding bytes added,
  25649.     // this is for files that are an exact multiple of the chunk
  25650.     // length. (Otherwise the padding isn't Translated)
  25651.     flen += MDxPad( lpData, flen, mlen );
  25652.     MD5Translate( lpData, flen, &mdDataSum );    
  25653.     MD4Translate( lpData, flen, &md4DataSum );
  25654.  
  25655.     // New step necessary because of the 'chunking' method
  25656.     MDxFinalize( &mdDataSum );
  25657.     MDxFinalize( &md4DataSum );
  25658.     
  25659.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25660.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25661.     fclose(file);
  25662.         
  25663. }
  25664.  
  25665. void DigestString()
  25666. {
  25667.     
  25668.     //For our demo purposes, no strings bigger than 1024 :)
  25669.     unsigned char lpData[1024] = "";
  25670.     long len = 0;
  25671.     MDxSum mdDataSum;
  25672.  
  25673.     printf("Enter the string to digest: ");
  25674.     scanf("%s", &lpData );
  25675.     len = strlen(lpData);
  25676.     
  25677.     // Have to do this before the Padding...well...it's best anyway;)
  25678.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25679.     
  25680.     // For the strings, we're gonna pad and digest the string
  25681.     // in one pass.
  25682.     MDxInit( &mdDataSum );
  25683.     MDxPad( lpData, len, len );
  25684.     
  25685.     MD5Translate( lpData, len, &mdDataSum );
  25686.         // New step necessary because of the 'chunking' method
  25687.         MDxFinalize( &mdDataSum );
  25688.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25689.     
  25690.     MDxInit( &mdDataSum );
  25691.     MD4Translate( lpData, len, &mdDataSum );    
  25692.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25693.  
  25694.     return;
  25695. }
  25696.  
  25697.  
  25698. -------------- Include
  25699.  
  25700. #ifndef __windows_h__
  25701.         typedef unsigned long DWORD;
  25702.         #define STDCALL _stdcall
  25703. #endif
  25704.  
  25705. typedef struct 
  25706. {
  25707.     DWORD dwSum[4];
  25708. }MDxSum;
  25709.  
  25710. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  25711. void STDCALL MDxInit( MDxSum * );
  25712. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  25713. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  25714. const char * STDCALL MDxGetVersion();
  25715. void STDCALL MDxFinalize( MDxSum * );
  25716.  
  25717.  
  25718. #include "mdx.h"
  25719. #include <stdlib.h>
  25720. #include <stdio.h>
  25721. #include <string.h>
  25722.  
  25723. // READLEN % 64 must = 0
  25724. #define READLEN    1048576L // 2^20, 1MB
  25725.  
  25726. void DigestFile( char * );
  25727. void DigestString();
  25728.  
  25729. void main(int argc, char *argv[])
  25730. {
  25731.     printf("%s\n\n", MDxGetVersion());
  25732.  
  25733.     if( argc > 1 )
  25734.         DigestFile( argv[1] );
  25735.     else    
  25736.         DigestString();
  25737.  
  25738. }
  25739.  
  25740. /*
  25741.     I use the 'chunk' method for processing files not because of
  25742.     limitations of my dll, but think what would happen if you
  25743.     tried to load an entire cd image into memory.
  25744. */
  25745. void DigestFile( char *szFName )
  25746. {
  25747.     FILE *file;
  25748.     void *lpData;
  25749.     long flen, mlen;
  25750.     MDxSum mdDataSum;
  25751.     MDxSum md4DataSum;
  25752.  
  25753.     // the 64 is for padding purposes
  25754.     lpData = malloc( READLEN + 64 );
  25755.     
  25756.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  25757.  
  25758.     file = fopen( szFName, "rb" );
  25759.     if( file == NULL )
  25760.     {
  25761.         printf("ERROR: File not found.\n");
  25762.         return;
  25763.     }
  25764.     
  25765.     MDxInit( &mdDataSum );
  25766.     MDxInit( &md4DataSum );
  25767.     
  25768.     fseek( file, 0, SEEK_END );
  25769.     //Get the file length
  25770.     flen = mlen = ftell( file );
  25771.     fseek( file, 0, SEEK_SET );
  25772.     
  25773.     // When it takes a while to process a large file,
  25774.     // remember that for each chunk it has to run 
  25775.     // through the main translation loop 16384 times!
  25776.         
  25777.     printf("Processing %ld byte file: .", flen );
  25778.     
  25779.     while( flen > READLEN )
  25780.     {
  25781.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25782.         {
  25783.             printf("READ ERROR!\n");
  25784.             return;
  25785.         }
  25786.         MD5Translate( lpData, READLEN, &mdDataSum );
  25787.         MD4Translate( lpData, READLEN, &md4DataSum );
  25788.         flen -= READLEN;
  25789.         printf(".");
  25790.     }
  25791.  
  25792.     if (fread( lpData, 1, flen, file ) != flen)
  25793.     {
  25794.         printf("READ ERROR!\n");
  25795.         return;
  25796.     }
  25797.     // This is why I added the new argument to MDxPad
  25798.     // So we can pass the length of the data AND the
  25799.     // Total length of the message
  25800.     // Also it now returns the # of padding bytes added,
  25801.     // this is for files that are an exact multiple of the chunk
  25802.     // length. (Otherwise the padding isn't Translated)
  25803.     flen += MDxPad( lpData, flen, mlen );
  25804.     MD5Translate( lpData, flen, &mdDataSum );    
  25805.     MD4Translate( lpData, flen, &md4DataSum );
  25806.  
  25807.     // New step necessary because of the 'chunking' method
  25808.     MDxFinalize( &mdDataSum );
  25809.     MDxFinalize( &md4DataSum );
  25810.     
  25811.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25812.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25813.     fclose(file);
  25814.         
  25815. }
  25816.  
  25817. void DigestString()
  25818. {
  25819.     
  25820.     //For our demo purposes, no strings bigger than 1024 :)
  25821.     unsigned char lpData[1024] = "";
  25822.     long len = 0;
  25823.     MDxSum mdDataSum;
  25824.  
  25825.     printf("Enter the string to digest: ");
  25826.     scanf("%s", &lpData );
  25827.     len = strlen(lpData);
  25828.     
  25829.     // Have to do this before the Padding...well...it's best anyway;)
  25830.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25831.     
  25832.     // For the strings, we're gonna pad and digest the string
  25833.     // in one pass.
  25834.     MDxInit( &mdDataSum );
  25835.     MDxPad( lpData, len, len );
  25836.     
  25837.     MD5Translate( lpData, len, &mdDataSum );
  25838.         // New step necessary because of the 'chunking' method
  25839.         MDxFinalize( &mdDataSum );
  25840.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25841.     
  25842.     MDxInit( &mdDataSum );
  25843.     MD4Translate( lpData, len, &mdDataSum );    
  25844.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25845.  
  25846.     return;
  25847. }
  25848.  
  25849.  
  25850. -------------- Include
  25851.  
  25852. #ifndef __windows_h__
  25853.         typedef unsigned long DWORD;
  25854.         #define STDCALL _stdcall
  25855. #endif
  25856.  
  25857. typedef struct 
  25858. {
  25859.     DWORD dwSum[4];
  25860. }MDxSum;
  25861.  
  25862. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  25863. void STDCALL MDxInit( MDxSum * );
  25864. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  25865. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  25866. const char * STDCALL MDxGetVersion();
  25867. void STDCALL MDxFinalize( MDxSum * );
  25868.  
  25869.  
  25870. #include "mdx.h"
  25871. #include <stdlib.h>
  25872. #include <stdio.h>
  25873. #include <string.h>
  25874.  
  25875. // READLEN % 64 must = 0
  25876. #define READLEN    1048576L // 2^20, 1MB
  25877.  
  25878. void DigestFile( char * );
  25879. void DigestString();
  25880.  
  25881. void main(int argc, char *argv[])
  25882. {
  25883.     printf("%s\n\n", MDxGetVersion());
  25884.  
  25885.     if( argc > 1 )
  25886.         DigestFile( argv[1] );
  25887.     else    
  25888.         DigestString();
  25889.  
  25890. }
  25891.  
  25892. /*
  25893.     I use the 'chunk' method for processing files not because of
  25894.     limitations of my dll, but think what would happen if you
  25895.     tried to load an entire cd image into memory.
  25896. */
  25897. void DigestFile( char *szFName )
  25898. {
  25899.     FILE *file;
  25900.     void *lpData;
  25901.     long flen, mlen;
  25902.     MDxSum mdDataSum;
  25903.     MDxSum md4DataSum;
  25904.  
  25905.     // the 64 is for padding purposes
  25906.     lpData = malloc( READLEN + 64 );
  25907.     
  25908.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  25909.  
  25910.     file = fopen( szFName, "rb" );
  25911.     if( file == NULL )
  25912.     {
  25913.         printf("ERROR: File not found.\n");
  25914.         return;
  25915.     }
  25916.     
  25917.     MDxInit( &mdDataSum );
  25918.     MDxInit( &md4DataSum );
  25919.     
  25920.     fseek( file, 0, SEEK_END );
  25921.     //Get the file length
  25922.     flen = mlen = ftell( file );
  25923.     fseek( file, 0, SEEK_SET );
  25924.     
  25925.     // When it takes a while to process a large file,
  25926.     // remember that for each chunk it has to run 
  25927.     // through the main translation loop 16384 times!
  25928.         
  25929.     printf("Processing %ld byte file: .", flen );
  25930.     
  25931.     while( flen > READLEN )
  25932.     {
  25933.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  25934.         {
  25935.             printf("READ ERROR!\n");
  25936.             return;
  25937.         }
  25938.         MD5Translate( lpData, READLEN, &mdDataSum );
  25939.         MD4Translate( lpData, READLEN, &md4DataSum );
  25940.         flen -= READLEN;
  25941.         printf(".");
  25942.     }
  25943.  
  25944.     if (fread( lpData, 1, flen, file ) != flen)
  25945.     {
  25946.         printf("READ ERROR!\n");
  25947.         return;
  25948.     }
  25949.     // This is why I added the new argument to MDxPad
  25950.     // So we can pass the length of the data AND the
  25951.     // Total length of the message
  25952.     // Also it now returns the # of padding bytes added,
  25953.     // this is for files that are an exact multiple of the chunk
  25954.     // length. (Otherwise the padding isn't Translated)
  25955.     flen += MDxPad( lpData, flen, mlen );
  25956.     MD5Translate( lpData, flen, &mdDataSum );    
  25957.     MD4Translate( lpData, flen, &md4DataSum );
  25958.  
  25959.     // New step necessary because of the 'chunking' method
  25960.     MDxFinalize( &mdDataSum );
  25961.     MDxFinalize( &md4DataSum );
  25962.     
  25963.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  25964.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25965.     fclose(file);
  25966.         
  25967. }
  25968.  
  25969. void DigestString()
  25970. {
  25971.     
  25972.     //For our demo purposes, no strings bigger than 1024 :)
  25973.     unsigned char lpData[1024] = "";
  25974.     long len = 0;
  25975.     MDxSum mdDataSum;
  25976.  
  25977.     printf("Enter the string to digest: ");
  25978.     scanf("%s", &lpData );
  25979.     len = strlen(lpData);
  25980.     
  25981.     // Have to do this before the Padding...well...it's best anyway;)
  25982.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  25983.     
  25984.     // For the strings, we're gonna pad and digest the string
  25985.     // in one pass.
  25986.     MDxInit( &mdDataSum );
  25987.     MDxPad( lpData, len, len );
  25988.     
  25989.     MD5Translate( lpData, len, &mdDataSum );
  25990.         // New step necessary because of the 'chunking' method
  25991.         MDxFinalize( &mdDataSum );
  25992.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25993.     
  25994.     MDxInit( &mdDataSum );
  25995.     MD4Translate( lpData, len, &mdDataSum );    
  25996.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  25997.  
  25998.     return;
  25999. }
  26000.  
  26001.  
  26002. -------------- Include
  26003.  
  26004. #ifndef __windows_h__
  26005.         typedef unsigned long DWORD;
  26006.         #define STDCALL _stdcall
  26007. #endif
  26008.  
  26009. typedef struct 
  26010. {
  26011.     DWORD dwSum[4];
  26012. }MDxSum;
  26013.  
  26014. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26015. void STDCALL MDxInit( MDxSum * );
  26016. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26017. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26018. const char * STDCALL MDxGetVersion();
  26019. void STDCALL MDxFinalize( MDxSum * );
  26020.  
  26021. #include "mdx.h"
  26022. #include <stdlib.h>
  26023. #include <stdio.h>
  26024. #include <string.h>
  26025.  
  26026. // READLEN % 64 must = 0
  26027. #define READLEN    1048576L // 2^20, 1MB
  26028.  
  26029. void DigestFile( char * );
  26030. void DigestString();
  26031.  
  26032. void main(int argc, char *argv[])
  26033. {
  26034.     printf("%s\n\n", MDxGetVersion());
  26035.  
  26036.     if( argc > 1 )
  26037.         DigestFile( argv[1] );
  26038.     else    
  26039.         DigestString();
  26040.  
  26041. }
  26042.  
  26043. /*
  26044.     I use the 'chunk' method for processing files not because of
  26045.     limitations of my dll, but think what would happen if you
  26046.     tried to load an entire cd image into memory.
  26047. */
  26048. void DigestFile( char *szFName )
  26049. {
  26050.     FILE *file;
  26051.     void *lpData;
  26052.     long flen, mlen;
  26053.     MDxSum mdDataSum;
  26054.     MDxSum md4DataSum;
  26055.  
  26056.     // the 64 is for padding purposes
  26057.     lpData = malloc( READLEN + 64 );
  26058.     
  26059.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26060.  
  26061.     file = fopen( szFName, "rb" );
  26062.     if( file == NULL )
  26063.     {
  26064.         printf("ERROR: File not found.\n");
  26065.         return;
  26066.     }
  26067.     
  26068.     MDxInit( &mdDataSum );
  26069.     MDxInit( &md4DataSum );
  26070.     
  26071.     fseek( file, 0, SEEK_END );
  26072.     //Get the file length
  26073.     flen = mlen = ftell( file );
  26074.     fseek( file, 0, SEEK_SET );
  26075.     
  26076.     // When it takes a while to process a large file,
  26077.     // remember that for each chunk it has to run 
  26078.     // through the main translation loop 16384 times!
  26079.         
  26080.     printf("Processing %ld byte file: .", flen );
  26081.     
  26082.     while( flen > READLEN )
  26083.     {
  26084.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  26085.         {
  26086.             printf("READ ERROR!\n");
  26087.             return;
  26088.         }
  26089.         MD5Translate( lpData, READLEN, &mdDataSum );
  26090.         MD4Translate( lpData, READLEN, &md4DataSum );
  26091.         flen -= READLEN;
  26092.         printf(".");
  26093.     }
  26094.  
  26095.     if (fread( lpData, 1, flen, file ) != flen)
  26096.     {
  26097.         printf("READ ERROR!\n");
  26098.         return;
  26099.     }
  26100.     // This is why I added the new argument to MDxPad
  26101.     // So we can pass the length of the data AND the
  26102.     // Total length of the message
  26103.     // Also it now returns the # of padding bytes added,
  26104.     // this is for files that are an exact multiple of the chunk
  26105.     // length. (Otherwise the padding isn't Translated)
  26106.     flen += MDxPad( lpData, flen, mlen );
  26107.     MD5Translate( lpData, flen, &mdDataSum );    
  26108.     MD4Translate( lpData, flen, &md4DataSum );
  26109.  
  26110.     // New step necessary because of the 'chunking' method
  26111.     MDxFinalize( &mdDataSum );
  26112.     MDxFinalize( &md4DataSum );
  26113.     
  26114.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  26115.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26116.     fclose(file);
  26117.         
  26118. }
  26119.  
  26120. void DigestString()
  26121. {
  26122.     
  26123.     //For our demo purposes, no strings bigger than 1024 :)
  26124.     unsigned char lpData[1024] = "";
  26125.     long len = 0;
  26126.     MDxSum mdDataSum;
  26127.  
  26128.     printf("Enter the string to digest: ");
  26129.     scanf("%s", &lpData );
  26130.     len = strlen(lpData);
  26131.     
  26132.     // Have to do this before the Padding...well...it's best anyway;)
  26133.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  26134.     
  26135.     // For the strings, we're gonna pad and digest the string
  26136.     // in one pass.
  26137.     MDxInit( &mdDataSum );
  26138.     MDxPad( lpData, len, len );
  26139.     
  26140.     MD5Translate( lpData, len, &mdDataSum );
  26141.         // New step necessary because of the 'chunking' method
  26142.         MDxFinalize( &mdDataSum );
  26143.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26144.     
  26145.     MDxInit( &mdDataSum );
  26146.     MD4Translate( lpData, len, &mdDataSum );    
  26147.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26148.  
  26149.     return;
  26150. }
  26151.  
  26152.  
  26153. -------------- Include
  26154.  
  26155. #ifndef __windows_h__
  26156.         typedef unsigned long DWORD;
  26157.         #define STDCALL _stdcall
  26158. #endif
  26159.  
  26160. typedef struct 
  26161. {
  26162.     DWORD dwSum[4];
  26163. }MDxSum;
  26164.  
  26165. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26166. void STDCALL MDxInit( MDxSum * );
  26167. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26168. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26169. const char * STDCALL MDxGetVersion();
  26170. void STDCALL MDxFinalize( MDxSum * );
  26171.  
  26172.  
  26173.  
  26174. #include "mdx.h"
  26175. #include <stdlib.h>
  26176. #include <stdio.h>
  26177. #include <string.h>
  26178.  
  26179. // READLEN % 64 must = 0
  26180. #define READLEN    1048576L // 2^20, 1MB
  26181.  
  26182. void DigestFile( char * );
  26183. void DigestString();
  26184.  
  26185. void main(int argc, char *argv[])
  26186. {
  26187.     printf("%s\n\n", MDxGetVersion());
  26188.  
  26189.     if( argc > 1 )
  26190.         DigestFile( argv[1] );
  26191.     else    
  26192.         DigestString();
  26193.  
  26194. }
  26195.  
  26196. /*
  26197.     I use the 'chunk' method for processing files not because of
  26198.     limitations of my dll, but think what would happen if you
  26199.     tried to load an entire cd image into memory.
  26200. */
  26201. void DigestFile( char *szFName )
  26202. {
  26203.     FILE *file;
  26204.     void *lpData;
  26205.     long flen, mlen;
  26206.     MDxSum mdDataSum;
  26207.     MDxSum md4DataSum;
  26208.  
  26209.     // the 64 is for padding purposes
  26210.     lpData = malloc( READLEN + 64 );
  26211.     
  26212.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26213.  
  26214.     file = fopen( szFName, "rb" );
  26215.     if( file == NULL )
  26216.     {
  26217.         printf("ERROR: File not found.\n");
  26218.         return;
  26219.     }
  26220.     
  26221.     MDxInit( &mdDataSum );
  26222.     MDxInit( &md4DataSum );
  26223.     
  26224.     fseek( file, 0, SEEK_END );
  26225.     //Get the file length
  26226.     flen = mlen = ftell( file );
  26227.     fseek( file, 0, SEEK_SET );
  26228.     
  26229.     // When it takes a while to process a large file,
  26230.     // remember that for each chunk it has to run 
  26231.     // through the main translation loop 16384 times!
  26232.         
  26233.     printf("Processing %ld byte file: .", flen );
  26234.     
  26235.     while( flen > READLEN )
  26236.     {
  26237.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  26238.         {
  26239.             printf("READ ERROR!\n");
  26240.             return;
  26241.         }
  26242.         MD5Translate( lpData, READLEN, &mdDataSum );
  26243.         MD4Translate( lpData, READLEN, &md4DataSum );
  26244.         flen -= READLEN;
  26245.         printf(".");
  26246.     }
  26247.  
  26248.     if (fread( lpData, 1, flen, file ) != flen)
  26249.     {
  26250.         printf("READ ERROR!\n");
  26251.         return;
  26252.     }
  26253.     // This is why I added the new argument to MDxPad
  26254.     // So we can pass the length of the data AND the
  26255.     // Total length of the message
  26256.     // Also it now returns the # of padding bytes added,
  26257.     // this is for files that are an exact multiple of the chunk
  26258.     // length. (Otherwise the padding isn't Translated)
  26259.     flen += MDxPad( lpData, flen, mlen );
  26260.     MD5Translate( lpData, flen, &mdDataSum );    
  26261.     MD4Translate( lpData, flen, &md4DataSum );
  26262.  
  26263.     // New step necessary because of the 'chunking' method
  26264.     MDxFinalize( &mdDataSum );
  26265.     MDxFinalize( &md4DataSum );
  26266.     
  26267.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  26268.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26269.     fclose(file);
  26270.         
  26271. }
  26272.  
  26273. void DigestString()
  26274. {
  26275.     
  26276.     //For our demo purposes, no strings bigger than 1024 :)
  26277.     unsigned char lpData[1024] = "";
  26278.     long len = 0;
  26279.     MDxSum mdDataSum;
  26280.  
  26281.     printf("Enter the string to digest: ");
  26282.     scanf("%s", &lpData );
  26283.     len = strlen(lpData);
  26284.     
  26285.     // Have to do this before the Padding...well...it's best anyway;)
  26286.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  26287.     
  26288.     // For the strings, we're gonna pad and digest the string
  26289.     // in one pass.
  26290.     MDxInit( &mdDataSum );
  26291.     MDxPad( lpData, len, len );
  26292.     
  26293.     MD5Translate( lpData, len, &mdDataSum );
  26294.         // New step necessary because of the 'chunking' method
  26295.         MDxFinalize( &mdDataSum );
  26296.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26297.     
  26298.     MDxInit( &mdDataSum );
  26299.     MD4Translate( lpData, len, &mdDataSum );    
  26300.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26301.  
  26302.     return;
  26303. }
  26304.  
  26305.  
  26306. -------------- Include
  26307.  
  26308. #ifndef __windows_h__
  26309.         typedef unsigned long DWORD;
  26310.         #define STDCALL _stdcall
  26311. #endif
  26312.  
  26313. typedef struct 
  26314. {
  26315.     DWORD dwSum[4];
  26316. }MDxSum;
  26317.  
  26318. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26319. void STDCALL MDxInit( MDxSum * );
  26320. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26321. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26322. const char * STDCALL MDxGetVersion();
  26323. void STDCALL MDxFinalize( MDxSum * );
  26324.  
  26325.  
  26326.  
  26327. #include "mdx.h"
  26328. #include <stdlib.h>
  26329. #include <stdio.h>
  26330. #include <string.h>
  26331.  
  26332. // READLEN % 64 must = 0
  26333. #define READLEN    1048576L // 2^20, 1MB
  26334.  
  26335. void DigestFile( char * );
  26336. void DigestString();
  26337.  
  26338. void main(int argc, char *argv[])
  26339. {
  26340.     printf("%s\n\n", MDxGetVersion());
  26341.  
  26342.     if( argc > 1 )
  26343.         DigestFile( argv[1] );
  26344.     else    
  26345.         DigestString();
  26346.  
  26347. }
  26348.  
  26349. /*
  26350.     I use the 'chunk' method for processing files not because of
  26351.     limitations of my dll, but think what would happen if you
  26352.     tried to load an entire cd image into memory.
  26353. */
  26354. void DigestFile( char *szFName )
  26355. {
  26356.     FILE *file;
  26357.     void *lpData;
  26358.     long flen, mlen;
  26359.     MDxSum mdDataSum;
  26360.     MDxSum md4DataSum;
  26361.  
  26362.     // the 64 is for padding purposes
  26363.     lpData = malloc( READLEN + 64 );
  26364.     
  26365.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26366.  
  26367.     file = fopen( szFName, "rb" );
  26368.     if( file == NULL )
  26369.     {
  26370.         printf("ERROR: File not found.\n");
  26371.         return;
  26372.     }
  26373.     
  26374.     MDxInit( &mdDataSum );
  26375.     MDxInit( &md4DataSum );
  26376.     
  26377.     fseek( file, 0, SEEK_END );
  26378.     //Get the file length
  26379.     flen = mlen = ftell( file );
  26380.     fseek( file, 0, SEEK_SET );
  26381.     
  26382.     // When it takes a while to process a large file,
  26383.     // remember that for each chunk it has to run 
  26384.     // through the main translation loop 16384 times!
  26385.         
  26386.     printf("Processing %ld byte file: .", flen );
  26387.     
  26388.     while( flen > READLEN )
  26389.     {
  26390.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  26391.         {
  26392.             printf("READ ERROR!\n");
  26393.             return;
  26394.         }
  26395.         MD5Translate( lpData, READLEN, &mdDataSum );
  26396.         MD4Translate( lpData, READLEN, &md4DataSum );
  26397.         flen -= READLEN;
  26398.         printf(".");
  26399.     }
  26400.  
  26401.     if (fread( lpData, 1, flen, file ) != flen)
  26402.     {
  26403.         printf("READ ERROR!\n");
  26404.         return;
  26405.     }
  26406.     // This is why I added the new argument to MDxPad
  26407.     // So we can pass the length of the data AND the
  26408.     // Total length of the message
  26409.     // Also it now returns the # of padding bytes added,
  26410.     // this is for files that are an exact multiple of the chunk
  26411.     // length. (Otherwise the padding isn't Translated)
  26412.     flen += MDxPad( lpData, flen, mlen );
  26413.     MD5Translate( lpData, flen, &mdDataSum );    
  26414.     MD4Translate( lpData, flen, &md4DataSum );
  26415.  
  26416.     // New step necessary because of the 'chunking' method
  26417.     MDxFinalize( &mdDataSum );
  26418.     MDxFinalize( &md4DataSum );
  26419.     
  26420.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  26421.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26422.     fclose(file);
  26423.         
  26424. }
  26425.  
  26426. void DigestString()
  26427. {
  26428.     
  26429.     //For our demo purposes, no strings bigger than 1024 :)
  26430.     unsigned char lpData[1024] = "";
  26431.     long len = 0;
  26432.     MDxSum mdDataSum;
  26433.  
  26434.     printf("Enter the string to digest: ");
  26435.     scanf("%s", &lpData );
  26436.     len = strlen(lpData);
  26437.     
  26438.     // Have to do this before the Padding...well...it's best anyway;)
  26439.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  26440.     
  26441.     // For the strings, we're gonna pad and digest the string
  26442.     // in one pass.
  26443.     MDxInit( &mdDataSum );
  26444.     MDxPad( lpData, len, len );
  26445.     
  26446.     MD5Translate( lpData, len, &mdDataSum );
  26447.         // New step necessary because of the 'chunking' method
  26448.         MDxFinalize( &mdDataSum );
  26449.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26450.     
  26451.     MDxInit( &mdDataSum );
  26452.     MD4Translate( lpData, len, &mdDataSum );    
  26453.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26454.  
  26455.     return;
  26456. }
  26457.  
  26458.  
  26459. -------------- Include
  26460.  
  26461. #ifndef __windows_h__
  26462.         typedef unsigned long DWORD;
  26463.         #define STDCALL _stdcall
  26464. #endif
  26465.  
  26466. typedef struct 
  26467. {
  26468.     DWORD dwSum[4];
  26469. }MDxSum;
  26470.  
  26471. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26472. void STDCALL MDxInit( MDxSum * );
  26473. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26474. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26475. const char * STDCALL MDxGetVersion();
  26476. void STDCALL MDxFinalize( MDxSum * );
  26477.  
  26478.  
  26479.  
  26480. #include "mdx.h"
  26481. #include <stdlib.h>
  26482. #include <stdio.h>
  26483. #include <string.h>
  26484.  
  26485. // READLEN % 64 must = 0
  26486. #define READLEN    1048576L // 2^20, 1MB
  26487.  
  26488. void DigestFile( char * );
  26489. void DigestString();
  26490.  
  26491. void main(int argc, char *argv[])
  26492. {
  26493.     printf("%s\n\n", MDxGetVersion());
  26494.  
  26495.     if( argc > 1 )
  26496.         DigestFile( argv[1] );
  26497.     else    
  26498.         DigestString();
  26499.  
  26500. }
  26501.  
  26502. /*
  26503.     I use the 'chunk' method for processing files not because of
  26504.     limitations of my dll, but think what would happen if you
  26505.     tried to load an entire cd image into memory.
  26506. */
  26507. void DigestFile( char *szFName )
  26508. {
  26509.     FILE *file;
  26510.     void *lpData;
  26511.     long flen, mlen;
  26512.     MDxSum mdDataSum;
  26513.     MDxSum md4DataSum;
  26514.  
  26515.     // the 64 is for padding purposes
  26516.     lpData = malloc( READLEN + 64 );
  26517.     
  26518.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26519.  
  26520.     file = fopen( szFName, "rb" );
  26521.     if( file == NULL )
  26522.     {
  26523.         printf("ERROR: File not found.\n");
  26524.         return;
  26525.     }
  26526.     
  26527.     MDxInit( &mdDataSum );
  26528.     MDxInit( &md4DataSum );
  26529.     
  26530.     fseek( file, 0, SEEK_END );
  26531.     //Get the file length
  26532.     flen = mlen = ftell( file );
  26533.     fseek( file, 0, SEEK_SET );
  26534.     
  26535.     // When it takes a while to process a large file,
  26536.     // remember that for each chunk it has to run 
  26537.     // through the main translation loop 16384 times!
  26538.         
  26539.     printf("Processing %ld byte file: .", flen );
  26540.     
  26541.     while( flen > READLEN )
  26542.     {
  26543.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  26544.         {
  26545.             printf("READ ERROR!\n");
  26546.             return;
  26547.         }
  26548.         MD5Translate( lpData, READLEN, &mdDataSum );
  26549.         MD4Translate( lpData, READLEN, &md4DataSum );
  26550.         flen -= READLEN;
  26551.         printf(".");
  26552.     }
  26553.  
  26554.     if (fread( lpData, 1, flen, file ) != flen)
  26555.     {
  26556.         printf("READ ERROR!\n");
  26557.         return;
  26558.     }
  26559.     // This is why I added the new argument to MDxPad
  26560.     // So we can pass the length of the data AND the
  26561.     // Total length of the message
  26562.     // Also it now returns the # of padding bytes added,
  26563.     // this is for files that are an exact multiple of the chunk
  26564.     // length. (Otherwise the padding isn't Translated)
  26565.     flen += MDxPad( lpData, flen, mlen );
  26566.     MD5Translate( lpData, flen, &mdDataSum );    
  26567.     MD4Translate( lpData, flen, &md4DataSum );
  26568.  
  26569.     // New step necessary because of the 'chunking' method
  26570.     MDxFinalize( &mdDataSum );
  26571.     MDxFinalize( &md4DataSum );
  26572.     
  26573.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  26574.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26575.     fclose(file);
  26576.         
  26577. }
  26578.  
  26579. void DigestString()
  26580. {
  26581.     
  26582.     //For our demo purposes, no strings bigger than 1024 :)
  26583.     unsigned char lpData[1024] = "";
  26584.     long len = 0;
  26585.     MDxSum mdDataSum;
  26586.  
  26587.     printf("Enter the string to digest: ");
  26588.     scanf("%s", &lpData );
  26589.     len = strlen(lpData);
  26590.     
  26591.     // Have to do this before the Padding...well...it's best anyway;)
  26592.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  26593.     
  26594.     // For the strings, we're gonna pad and digest the string
  26595.     // in one pass.
  26596.     MDxInit( &mdDataSum );
  26597.     MDxPad( lpData, len, len );
  26598.     
  26599.     MD5Translate( lpData, len, &mdDataSum );
  26600.         // New step necessary because of the 'chunking' method
  26601.         MDxFinalize( &mdDataSum );
  26602.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26603.     
  26604.     MDxInit( &mdDataSum );
  26605.     MD4Translate( lpData, len, &mdDataSum );    
  26606.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26607.  
  26608.     return;
  26609. }
  26610.  
  26611.  
  26612. -------------- Include
  26613.  
  26614. #ifndef __windows_h__
  26615.         typedef unsigned long DWORD;
  26616.         #define STDCALL _stdcall
  26617. #endif
  26618.  
  26619. typedef struct 
  26620. {
  26621.     DWORD dwSum[4];
  26622. }MDxSum;
  26623.  
  26624. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26625. void STDCALL MDxInit( MDxSum * );
  26626. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26627. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26628. const char * STDCALL MDxGetVersion();
  26629. void STDCALL MDxFinalize( MDxSum * );
  26630.  
  26631.  
  26632.  
  26633. #include "mdx.h"
  26634. #include <stdlib.h>
  26635. #include <stdio.h>
  26636. #include <string.h>
  26637.  
  26638. // READLEN % 64 must = 0
  26639. #define READLEN    1048576L // 2^20, 1MB
  26640.  
  26641. void DigestFile( char * );
  26642. void DigestString();
  26643.  
  26644. void main(int argc, char *argv[])
  26645. {
  26646.     printf("%s\n\n", MDxGetVersion());
  26647.  
  26648.     if( argc > 1 )
  26649.         DigestFile( argv[1] );
  26650.     else    
  26651.         DigestString();
  26652.  
  26653. }
  26654.  
  26655. /*
  26656.     I use the 'chunk' method for processing files not because of
  26657.     limitations of my dll, but think what would happen if you
  26658.     tried to load an entire cd image into memory.
  26659. */
  26660. void DigestFile( char *szFName )
  26661. {
  26662.     FILE *file;
  26663.     void *lpData;
  26664.     long flen, mlen;
  26665.     MDxSum mdDataSum;
  26666.     MDxSum md4DataSum;
  26667.  
  26668.     // the 64 is for padding purposes
  26669.     lpData = malloc( READLEN + 64 );
  26670.     
  26671.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26672.  
  26673.     file = fopen( szFName, "rb" );
  26674.     if( file == NULL )
  26675.     {
  26676.         printf("ERROR: File not found.\n");
  26677.         return;
  26678.     }
  26679.     
  26680.     MDxInit( &mdDataSum );
  26681.     MDxInit( &md4DataSum );
  26682.     
  26683.     fseek( file, 0, SEEK_END );
  26684.     //Get the file length
  26685.     flen = mlen = ftell( file );
  26686.     fseek( file, 0, SEEK_SET );
  26687.     
  26688.     // When it takes a while to process a large file,
  26689.     // remember that for each chunk it has to run 
  26690.     // through the main translation loop 16384 times!
  26691.         
  26692.     printf("Processing %ld byte file: .", flen );
  26693.     
  26694.     while( flen > READLEN )
  26695.     {
  26696.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  26697.         {
  26698.             printf("READ ERROR!\n");
  26699.             return;
  26700.         }
  26701.         MD5Translate( lpData, READLEN, &mdDataSum );
  26702.         MD4Translate( lpData, READLEN, &md4DataSum );
  26703.         flen -= READLEN;
  26704.         printf(".");
  26705.     }
  26706.  
  26707.     if (fread( lpData, 1, flen, file ) != flen)
  26708.     {
  26709.         printf("READ ERROR!\n");
  26710.         return;
  26711.     }
  26712.     // This is why I added the new argument to MDxPad
  26713.     // So we can pass the length of the data AND the
  26714.     // Total length of the message
  26715.     // Also it now returns the # of padding bytes added,
  26716.     // this is for files that are an exact multiple of the chunk
  26717.     // length. (Otherwise the padding isn't Translated)
  26718.     flen += MDxPad( lpData, flen, mlen );
  26719.     MD5Translate( lpData, flen, &mdDataSum );    
  26720.     MD4Translate( lpData, flen, &md4DataSum );
  26721.  
  26722.     // New step necessary because of the 'chunking' method
  26723.     MDxFinalize( &mdDataSum );
  26724.     MDxFinalize( &md4DataSum );
  26725.     
  26726.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  26727.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26728.     fclose(file);
  26729.         
  26730. }
  26731.  
  26732. void DigestString()
  26733. {
  26734.     
  26735.     //For our demo purposes, no strings bigger than 1024 :)
  26736.     unsigned char lpData[1024] = "";
  26737.     long len = 0;
  26738.     MDxSum mdDataSum;
  26739.  
  26740.     printf("Enter the string to digest: ");
  26741.     scanf("%s", &lpData );
  26742.     len = strlen(lpData);
  26743.     
  26744.     // Have to do this before the Padding...well...it's best anyway;)
  26745.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  26746.     
  26747.     // For the strings, we're gonna pad and digest the string
  26748.     // in one pass.
  26749.     MDxInit( &mdDataSum );
  26750.     MDxPad( lpData, len, len );
  26751.     
  26752.     MD5Translate( lpData, len, &mdDataSum );
  26753.         // New step necessary because of the 'chunking' method
  26754.         MDxFinalize( &mdDataSum );
  26755.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26756.     
  26757.     MDxInit( &mdDataSum );
  26758.     MD4Translate( lpData, len, &mdDataSum );    
  26759.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26760.  
  26761.     return;
  26762. }
  26763.  
  26764.  
  26765. -------------- Include
  26766.  
  26767. #ifndef __windows_h__
  26768.         typedef unsigned long DWORD;
  26769.         #define STDCALL _stdcall
  26770. #endif
  26771.  
  26772. typedef struct 
  26773. {
  26774.     DWORD dwSum[4];
  26775. }MDxSum;
  26776.  
  26777. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26778. void STDCALL MDxInit( MDxSum * );
  26779. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26780. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26781. const char * STDCALL MDxGetVersion();
  26782. void STDCALL MDxFinalize( MDxSum * );
  26783.  
  26784.  
  26785.  
  26786.  
  26787. #include "mdx.h"
  26788. #include <stdlib.h>
  26789. #include <stdio.h>
  26790. #include <string.h>
  26791.  
  26792. // READLEN % 64 must = 0
  26793. #define READLEN    1048576L // 2^20, 1MB
  26794.  
  26795. void DigestFile( char * );
  26796. void DigestString();
  26797.  
  26798. void main(int argc, char *argv[])
  26799. {
  26800.     printf("%s\n\n", MDxGetVersion());
  26801.  
  26802.     if( argc > 1 )
  26803.         DigestFile( argv[1] );
  26804.     else    
  26805.         DigestString();
  26806.  
  26807. }
  26808.  
  26809. /*
  26810.     I use the 'chunk' method for processing files not because of
  26811.     limitations of my dll, but think what would happen if you
  26812.     tried to load an entire cd image into memory.
  26813. */
  26814. void DigestFile( char *szFName )
  26815. {
  26816.     FILE *file;
  26817.     void *lpData;
  26818.     long flen, mlen;
  26819.     MDxSum mdDataSum;
  26820.     MDxSum md4DataSum;
  26821.  
  26822.     // the 64 is for padding purposes
  26823.     lpData = malloc( READLEN + 64 );
  26824.     
  26825.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26826.  
  26827.     file = fopen( szFName, "rb" );
  26828.     if( file == NULL )
  26829.     {
  26830.         printf("ERROR: File not found.\n");
  26831.         return;
  26832.     }
  26833.     
  26834.     MDxInit( &mdDataSum );
  26835.     MDxInit( &md4DataSum );
  26836.     
  26837.     fseek( file, 0, SEEK_END );
  26838.     //Get the file length
  26839.     flen = mlen = ftell( file );
  26840.     fseek( file, 0, SEEK_SET );
  26841.     
  26842.     // When it takes a while to process a large file,
  26843.     // remember that for each chunk it has to run 
  26844.     // through the main translation loop 16384 times!
  26845.         
  26846.     printf("Processing %ld byte file: .", flen );
  26847.     
  26848.     while( flen > READLEN )
  26849.     {
  26850.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  26851.         {
  26852.             printf("READ ERROR!\n");
  26853.             return;
  26854.         }
  26855.         MD5Translate( lpData, READLEN, &mdDataSum );
  26856.         MD4Translate( lpData, READLEN, &md4DataSum );
  26857.         flen -= READLEN;
  26858.         printf(".");
  26859.     }
  26860.  
  26861.     if (fread( lpData, 1, flen, file ) != flen)
  26862.     {
  26863.         printf("READ ERROR!\n");
  26864.         return;
  26865.     }
  26866.     // This is why I added the new argument to MDxPad
  26867.     // So we can pass the length of the data AND the
  26868.     // Total length of the message
  26869.     // Also it now returns the # of padding bytes added,
  26870.     // this is for files that are an exact multiple of the chunk
  26871.     // length. (Otherwise the padding isn't Translated)
  26872.     flen += MDxPad( lpData, flen, mlen );
  26873.     MD5Translate( lpData, flen, &mdDataSum );    
  26874.     MD4Translate( lpData, flen, &md4DataSum );
  26875.  
  26876.     // New step necessary because of the 'chunking' method
  26877.     MDxFinalize( &mdDataSum );
  26878.     MDxFinalize( &md4DataSum );
  26879.     
  26880.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  26881.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26882.     fclose(file);
  26883.         
  26884. }
  26885.  
  26886. void DigestString()
  26887. {
  26888.     
  26889.     //For our demo purposes, no strings bigger than 1024 :)
  26890.     unsigned char lpData[1024] = "";
  26891.     long len = 0;
  26892.     MDxSum mdDataSum;
  26893.  
  26894.     printf("Enter the string to digest: ");
  26895.     scanf("%s", &lpData );
  26896.     len = strlen(lpData);
  26897.     
  26898.     // Have to do this before the Padding...well...it's best anyway;)
  26899.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  26900.     
  26901.     // For the strings, we're gonna pad and digest the string
  26902.     // in one pass.
  26903.     MDxInit( &mdDataSum );
  26904.     MDxPad( lpData, len, len );
  26905.     
  26906.     MD5Translate( lpData, len, &mdDataSum );
  26907.         // New step necessary because of the 'chunking' method
  26908.         MDxFinalize( &mdDataSum );
  26909.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26910.     
  26911.     MDxInit( &mdDataSum );
  26912.     MD4Translate( lpData, len, &mdDataSum );    
  26913.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  26914.  
  26915.     return;
  26916. }
  26917.  
  26918.  
  26919. -------------- Include
  26920.  
  26921. #ifndef __windows_h__
  26922.         typedef unsigned long DWORD;
  26923.         #define STDCALL _stdcall
  26924. #endif
  26925.  
  26926. typedef struct 
  26927. {
  26928.     DWORD dwSum[4];
  26929. }MDxSum;
  26930.  
  26931. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  26932. void STDCALL MDxInit( MDxSum * );
  26933. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  26934. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  26935. const char * STDCALL MDxGetVersion();
  26936. void STDCALL MDxFinalize( MDxSum * );
  26937.  
  26938.  
  26939.  
  26940.  
  26941. #include "mdx.h"
  26942. #include <stdlib.h>
  26943. #include <stdio.h>
  26944. #include <string.h>
  26945.  
  26946. // READLEN % 64 must = 0
  26947. #define READLEN    1048576L // 2^20, 1MB
  26948.  
  26949. void DigestFile( char * );
  26950. void DigestString();
  26951.  
  26952. void main(int argc, char *argv[])
  26953. {
  26954.     printf("%s\n\n", MDxGetVersion());
  26955.  
  26956.     if( argc > 1 )
  26957.         DigestFile( argv[1] );
  26958.     else    
  26959.         DigestString();
  26960.  
  26961. }
  26962.  
  26963. /*
  26964.     I use the 'chunk' method for processing files not because of
  26965.     limitations of my dll, but think what would happen if you
  26966.     tried to load an entire cd image into memory.
  26967. */
  26968. void DigestFile( char *szFName )
  26969. {
  26970.     FILE *file;
  26971.     void *lpData;
  26972.     long flen, mlen;
  26973.     MDxSum mdDataSum;
  26974.     MDxSum md4DataSum;
  26975.  
  26976.     // the 64 is for padding purposes
  26977.     lpData = malloc( READLEN + 64 );
  26978.     
  26979.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  26980.  
  26981.     file = fopen( szFName, "rb" );
  26982.     if( file == NULL )
  26983.     {
  26984.         printf("ERROR: File not found.\n");
  26985.         return;
  26986.     }
  26987.     
  26988.     MDxInit( &mdDataSum );
  26989.     MDxInit( &md4DataSum );
  26990.     
  26991.     fseek( file, 0, SEEK_END );
  26992.     //Get the file length
  26993.     flen = mlen = ftell( file );
  26994.     fseek( file, 0, SEEK_SET );
  26995.     
  26996.     // When it takes a while to process a large file,
  26997.     // remember that for each chunk it has to run 
  26998.     // through the main translation loop 16384 times!
  26999.         
  27000.     printf("Processing %ld byte file: .", flen );
  27001.     
  27002.     while( flen > READLEN )
  27003.     {
  27004.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27005.         {
  27006.             printf("READ ERROR!\n");
  27007.             return;
  27008.         }
  27009.         MD5Translate( lpData, READLEN, &mdDataSum );
  27010.         MD4Translate( lpData, READLEN, &md4DataSum );
  27011.         flen -= READLEN;
  27012.         printf(".");
  27013.     }
  27014.  
  27015.     if (fread( lpData, 1, flen, file ) != flen)
  27016.     {
  27017.         printf("READ ERROR!\n");
  27018.         return;
  27019.     }
  27020.     // This is why I added the new argument to MDxPad
  27021.     // So we can pass the length of the data AND the
  27022.     // Total length of the message
  27023.     // Also it now returns the # of padding bytes added,
  27024.     // this is for files that are an exact multiple of the chunk
  27025.     // length. (Otherwise the padding isn't Translated)
  27026.     flen += MDxPad( lpData, flen, mlen );
  27027.     MD5Translate( lpData, flen, &mdDataSum );    
  27028.     MD4Translate( lpData, flen, &md4DataSum );
  27029.  
  27030.     // New step necessary because of the 'chunking' method
  27031.     MDxFinalize( &mdDataSum );
  27032.     MDxFinalize( &md4DataSum );
  27033.     
  27034.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27035.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27036.     fclose(file);
  27037.         
  27038. }
  27039.  
  27040. void DigestString()
  27041. {
  27042.     
  27043.     //For our demo purposes, no strings bigger than 1024 :)
  27044.     unsigned char lpData[1024] = "";
  27045.     long len = 0;
  27046.     MDxSum mdDataSum;
  27047.  
  27048.     printf("Enter the string to digest: ");
  27049.     scanf("%s", &lpData );
  27050.     len = strlen(lpData);
  27051.     
  27052.     // Have to do this before the Padding...well...it's best anyway;)
  27053.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27054.     
  27055.     // For the strings, we're gonna pad and digest the string
  27056.     // in one pass.
  27057.     MDxInit( &mdDataSum );
  27058.     MDxPad( lpData, len, len );
  27059.     
  27060.     MD5Translate( lpData, len, &mdDataSum );
  27061.         // New step necessary because of the 'chunking' method
  27062.         MDxFinalize( &mdDataSum );
  27063.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27064.     
  27065.     MDxInit( &mdDataSum );
  27066.     MD4Translate( lpData, len, &mdDataSum );    
  27067.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27068.  
  27069.     return;
  27070. }
  27071.  
  27072.  
  27073. -------------- Include
  27074.  
  27075. #ifndef __windows_h__
  27076.         typedef unsigned long DWORD;
  27077.         #define STDCALL _stdcall
  27078. #endif
  27079.  
  27080. typedef struct 
  27081. {
  27082.     DWORD dwSum[4];
  27083. }MDxSum;
  27084.  
  27085. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  27086. void STDCALL MDxInit( MDxSum * );
  27087. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  27088. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  27089. const char * STDCALL MDxGetVersion();
  27090. void STDCALL MDxFinalize( MDxSum * );
  27091.  
  27092.  
  27093.  
  27094.  
  27095. #include "mdx.h"
  27096. #include <stdlib.h>
  27097. #include <stdio.h>
  27098. #include <string.h>
  27099.  
  27100. // READLEN % 64 must = 0
  27101. #define READLEN    1048576L // 2^20, 1MB
  27102.  
  27103. void DigestFile( char * );
  27104. void DigestString();
  27105.  
  27106. void main(int argc, char *argv[])
  27107. {
  27108.     printf("%s\n\n", MDxGetVersion());
  27109.  
  27110.     if( argc > 1 )
  27111.         DigestFile( argv[1] );
  27112.     else    
  27113.         DigestString();
  27114.  
  27115. }
  27116.  
  27117. /*
  27118.     I use the 'chunk' method for processing files not because of
  27119.     limitations of my dll, but think what would happen if you
  27120.     tried to load an entire cd image into memory.
  27121. */
  27122. void DigestFile( char *szFName )
  27123. {
  27124.     FILE *file;
  27125.     void *lpData;
  27126.     long flen, mlen;
  27127.     MDxSum mdDataSum;
  27128.     MDxSum md4DataSum;
  27129.  
  27130.     // the 64 is for padding purposes
  27131.     lpData = malloc( READLEN + 64 );
  27132.     
  27133.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  27134.  
  27135.     file = fopen( szFName, "rb" );
  27136.     if( file == NULL )
  27137.     {
  27138.         printf("ERROR: File not found.\n");
  27139.         return;
  27140.     }
  27141.     
  27142.     MDxInit( &mdDataSum );
  27143.     MDxInit( &md4DataSum );
  27144.     
  27145.     fseek( file, 0, SEEK_END );
  27146.     //Get the file length
  27147.     flen = mlen = ftell( file );
  27148.     fseek( file, 0, SEEK_SET );
  27149.     
  27150.     // When it takes a while to process a large file,
  27151.     // remember that for each chunk it has to run 
  27152.     // through the main translation loop 16384 times!
  27153.         
  27154.     printf("Processing %ld byte file: .", flen );
  27155.     
  27156.     while( flen > READLEN )
  27157.     {
  27158.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27159.         {
  27160.             printf("READ ERROR!\n");
  27161.             return;
  27162.         }
  27163.         MD5Translate( lpData, READLEN, &mdDataSum );
  27164.         MD4Translate( lpData, READLEN, &md4DataSum );
  27165.         flen -= READLEN;
  27166.         printf(".");
  27167.     }
  27168.  
  27169.     if (fread( lpData, 1, flen, file ) != flen)
  27170.     {
  27171.         printf("READ ERROR!\n");
  27172.         return;
  27173.     }
  27174.     // This is why I added the new argument to MDxPad
  27175.     // So we can pass the length of the data AND the
  27176.     // Total length of the message
  27177.     // Also it now returns the # of padding bytes added,
  27178.     // this is for files that are an exact multiple of the chunk
  27179.     // length. (Otherwise the padding isn't Translated)
  27180.     flen += MDxPad( lpData, flen, mlen );
  27181.     MD5Translate( lpData, flen, &mdDataSum );    
  27182.     MD4Translate( lpData, flen, &md4DataSum );
  27183.  
  27184.     // New step necessary because of the 'chunking' method
  27185.     MDxFinalize( &mdDataSum );
  27186.     MDxFinalize( &md4DataSum );
  27187.     
  27188.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27189.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27190.     fclose(file);
  27191.         
  27192. }
  27193.  
  27194. void DigestString()
  27195. {
  27196.     
  27197.     //For our demo purposes, no strings bigger than 1024 :)
  27198.     unsigned char lpData[1024] = "";
  27199.     long len = 0;
  27200.     MDxSum mdDataSum;
  27201.  
  27202.     printf("Enter the string to digest: ");
  27203.     scanf("%s", &lpData );
  27204.     len = strlen(lpData);
  27205.     
  27206.     // Have to do this before the Padding...well...it's best anyway;)
  27207.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27208.     
  27209.     // For the strings, we're gonna pad and digest the string
  27210.     // in one pass.
  27211.     MDxInit( &mdDataSum );
  27212.     MDxPad( lpData, len, len );
  27213.     
  27214.     MD5Translate( lpData, len, &mdDataSum );
  27215.         // New step necessary because of the 'chunking' method
  27216.         MDxFinalize( &mdDataSum );
  27217.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27218.     
  27219.     MDxInit( &mdDataSum );
  27220.     MD4Translate( lpData, len, &mdDataSum );    
  27221.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27222.  
  27223.     return;
  27224. }
  27225.  
  27226.  
  27227. -------------- Include
  27228.  
  27229. #ifndef __windows_h__
  27230.         typedef unsigned long DWORD;
  27231.         #define STDCALL _stdcall
  27232. #endif
  27233.  
  27234. typedef struct 
  27235. {
  27236.     DWORD dwSum[4];
  27237. }MDxSum;
  27238.  
  27239. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  27240. void STDCALL MDxInit( MDxSum * );
  27241. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  27242. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  27243. const char * STDCALL MDxGetVersion();
  27244. void STDCALL MDxFinalize( MDxSum * );
  27245.  
  27246.  
  27247.  
  27248. #include "mdx.h"
  27249. #include <stdlib.h>
  27250. #include <stdio.h>
  27251. #include <string.h>
  27252.  
  27253. // READLEN % 64 must = 0
  27254. #define READLEN    1048576L // 2^20, 1MB
  27255.  
  27256. void DigestFile( char * );
  27257. void DigestString();
  27258.  
  27259. void main(int argc, char *argv[])
  27260. {
  27261.     printf("%s\n\n", MDxGetVersion());
  27262.  
  27263.     if( argc > 1 )
  27264.         DigestFile( argv[1] );
  27265.     else    
  27266.         DigestString();
  27267.  
  27268. }
  27269.  
  27270. /*
  27271.     I use the 'chunk' method for processing files not because of
  27272.     limitations of my dll, but think what would happen if you
  27273.     tried to load an entire cd image into memory.
  27274. */
  27275. void DigestFile( char *szFName )
  27276. {
  27277.     FILE *file;
  27278.     void *lpData;
  27279.     long flen, mlen;
  27280.     MDxSum mdDataSum;
  27281.     MDxSum md4DataSum;
  27282.  
  27283.     // the 64 is for padding purposes
  27284.     lpData = malloc( READLEN + 64 );
  27285.     
  27286.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  27287.  
  27288.     file = fopen( szFName, "rb" );
  27289.     if( file == NULL )
  27290.     {
  27291.         printf("ERROR: File not found.\n");
  27292.         return;
  27293.     }
  27294.     
  27295.     MDxInit( &mdDataSum );
  27296.     MDxInit( &md4DataSum );
  27297.     
  27298.     fseek( file, 0, SEEK_END );
  27299.     //Get the file length
  27300.     flen = mlen = ftell( file );
  27301.     fseek( file, 0, SEEK_SET );
  27302.     
  27303.     // When it takes a while to process a large file,
  27304.     // remember that for each chunk it has to run 
  27305.     // through the main translation loop 16384 times!
  27306.         
  27307.     printf("Processing %ld byte file: .", flen );
  27308.     
  27309.     while( flen > READLEN )
  27310.     {
  27311.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27312.         {
  27313.             printf("READ ERROR!\n");
  27314.             return;
  27315.         }
  27316.         MD5Translate( lpData, READLEN, &mdDataSum );
  27317.         MD4Translate( lpData, READLEN, &md4DataSum );
  27318.         flen -= READLEN;
  27319.         printf(".");
  27320.     }
  27321.  
  27322.     if (fread( lpData, 1, flen, file ) != flen)
  27323.     {
  27324.         printf("READ ERROR!\n");
  27325.         return;
  27326.     }
  27327.     // This is why I added the new argument to MDxPad
  27328.     // So we can pass the length of the data AND the
  27329.     // Total length of the message
  27330.     // Also it now returns the # of padding bytes added,
  27331.     // this is for files that are an exact multiple of the chunk
  27332.     // length. (Otherwise the padding isn't Translated)
  27333.     flen += MDxPad( lpData, flen, mlen );
  27334.     MD5Translate( lpData, flen, &mdDataSum );    
  27335.     MD4Translate( lpData, flen, &md4DataSum );
  27336.  
  27337.     // New step necessary because of the 'chunking' method
  27338.     MDxFinalize( &mdDataSum );
  27339.     MDxFinalize( &md4DataSum );
  27340.     
  27341.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27342.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27343.     fclose(file);
  27344.         
  27345. }
  27346.  
  27347. void DigestString()
  27348. {
  27349.     
  27350.     //For our demo purposes, no strings bigger than 1024 :)
  27351.     unsigned char lpData[1024] = "";
  27352.     long len = 0;
  27353.     MDxSum mdDataSum;
  27354.  
  27355.     printf("Enter the string to digest: ");
  27356.     scanf("%s", &lpData );
  27357.     len = strlen(lpData);
  27358.     
  27359.     // Have to do this before the Padding...well...it's best anyway;)
  27360.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27361.     
  27362.     // For the strings, we're gonna pad and digest the string
  27363.     // in one pass.
  27364.     MDxInit( &mdDataSum );
  27365.     MDxPad( lpData, len, len );
  27366.     
  27367.     MD5Translate( lpData, len, &mdDataSum );
  27368.         // New step necessary because of the 'chunking' method
  27369.         MDxFinalize( &mdDataSum );
  27370.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27371.     
  27372.     MDxInit( &mdDataSum );
  27373.     MD4Translate( lpData, len, &mdDataSum );    
  27374.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27375.  
  27376.     return;
  27377. }
  27378.  
  27379.  
  27380. -------------- Include
  27381.  
  27382. #ifndef __windows_h__
  27383.         typedef unsigned long DWORD;
  27384.         #define STDCALL _stdcall
  27385. #endif
  27386.  
  27387. typedef struct 
  27388. {
  27389.     DWORD dwSum[4];
  27390. }MDxSum;
  27391.  
  27392. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  27393. void STDCALL MDxInit( MDxSum * );
  27394. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  27395. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  27396. const char * STDCALL MDxGetVersion();
  27397. void STDCALL MDxFinalize( MDxSum * );
  27398.  
  27399.  
  27400.  
  27401. #include "mdx.h"
  27402. #include <stdlib.h>
  27403. #include <stdio.h>
  27404. #include <string.h>
  27405.  
  27406. // READLEN % 64 must = 0
  27407. #define READLEN    1048576L // 2^20, 1MB
  27408.  
  27409. void DigestFile( char * );
  27410. void DigestString();
  27411.  
  27412. void main(int argc, char *argv[])
  27413. {
  27414.     printf("%s\n\n", MDxGetVersion());
  27415.  
  27416.     if( argc > 1 )
  27417.         DigestFile( argv[1] );
  27418.     else    
  27419.         DigestString();
  27420.  
  27421. }
  27422.  
  27423. /*
  27424.     I use the 'chunk' method for processing files not because of
  27425.     limitations of my dll, but think what would happen if you
  27426.     tried to load an entire cd image into memory.
  27427. */
  27428. void DigestFile( char *szFName )
  27429. {
  27430.     FILE *file;
  27431.     void *lpData;
  27432.     long flen, mlen;
  27433.     MDxSum mdDataSum;
  27434.     MDxSum md4DataSum;
  27435.  
  27436.     // the 64 is for padding purposes
  27437.     lpData = malloc( READLEN + 64 );
  27438.     
  27439.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  27440.  
  27441.     file = fopen( szFName, "rb" );
  27442.     if( file == NULL )
  27443.     {
  27444.         printf("ERROR: File not found.\n");
  27445.         return;
  27446.     }
  27447.     
  27448.     MDxInit( &mdDataSum );
  27449.     MDxInit( &md4DataSum );
  27450.     
  27451.     fseek( file, 0, SEEK_END );
  27452.     //Get the file length
  27453.     flen = mlen = ftell( file );
  27454.     fseek( file, 0, SEEK_SET );
  27455.     
  27456.     // When it takes a while to process a large file,
  27457.     // remember that for each chunk it has to run 
  27458.     // through the main translation loop 16384 times!
  27459.         
  27460.     printf("Processing %ld byte file: .", flen );
  27461.     
  27462.     while( flen > READLEN )
  27463.     {
  27464.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27465.         {
  27466.             printf("READ ERROR!\n");
  27467.             return;
  27468.         }
  27469.         MD5Translate( lpData, READLEN, &mdDataSum );
  27470.         MD4Translate( lpData, READLEN, &md4DataSum );
  27471.         flen -= READLEN;
  27472.         printf(".");
  27473.     }
  27474.  
  27475.     if (fread( lpData, 1, flen, file ) != flen)
  27476.     {
  27477.         printf("READ ERROR!\n");
  27478.         return;
  27479.     }
  27480.     // This is why I added the new argument to MDxPad
  27481.     // So we can pass the length of the data AND the
  27482.     // Total length of the message
  27483.     // Also it now returns the # of padding bytes added,
  27484.     // this is for files that are an exact multiple of the chunk
  27485.     // length. (Otherwise the padding isn't Translated)
  27486.     flen += MDxPad( lpData, flen, mlen );
  27487.     MD5Translate( lpData, flen, &mdDataSum );    
  27488.     MD4Translate( lpData, flen, &md4DataSum );
  27489.  
  27490.     // New step necessary because of the 'chunking' method
  27491.     MDxFinalize( &mdDataSum );
  27492.     MDxFinalize( &md4DataSum );
  27493.     
  27494.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27495.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27496.     fclose(file);
  27497.         
  27498. }
  27499.  
  27500. void DigestString()
  27501. {
  27502.     
  27503.     //For our demo purposes, no strings bigger than 1024 :)
  27504.     unsigned char lpData[1024] = "";
  27505.     long len = 0;
  27506.     MDxSum mdDataSum;
  27507.  
  27508.     printf("Enter the string to digest: ");
  27509.     scanf("%s", &lpData );
  27510.     len = strlen(lpData);
  27511.     
  27512.     // Have to do this before the Padding...well...it's best anyway;)
  27513.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27514.     
  27515.     // For the strings, we're gonna pad and digest the string
  27516.     // in one pass.
  27517.     MDxInit( &mdDataSum );
  27518.     MDxPad( lpData, len, len );
  27519.     
  27520.     MD5Translate( lpData, len, &mdDataSum );
  27521.         // New step necessary because of the 'chunking' method
  27522.         MDxFinalize( &mdDataSum );
  27523.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27524.     
  27525.     MDxInit( &mdDataSum );
  27526.     MD4Translate( lpData, len, &mdDataSum );    
  27527.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27528.  
  27529.     return;
  27530. }
  27531.  
  27532.  
  27533. -------------- Include
  27534.  
  27535. #ifndef __windows_h__
  27536.         typedef unsigned long DWORD;
  27537.         #define STDCALL _stdcall
  27538. #endif
  27539.  
  27540. typedef struct 
  27541. {
  27542.     DWORD dwSum[4];
  27543. }MDxSum;
  27544.  
  27545. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  27546. void STDCALL MDxInit( MDxSum * );
  27547. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  27548. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  27549. const char * STDCALL MDxGetVersion();
  27550. void STDCALL MDxFinalize( MDxSum * );
  27551.  
  27552.  
  27553.  
  27554.  
  27555. #include "mdx.h"
  27556. #include <stdlib.h>
  27557. #include <stdio.h>
  27558. #include <string.h>
  27559.  
  27560. // READLEN % 64 must = 0
  27561. #define READLEN    1048576L // 2^20, 1MB
  27562.  
  27563. void DigestFile( char * );
  27564. void DigestString();
  27565.  
  27566. void main(int argc, char *argv[])
  27567. {
  27568.     printf("%s\n\n", MDxGetVersion());
  27569.  
  27570.     if( argc > 1 )
  27571.         DigestFile( argv[1] );
  27572.     else    
  27573.         DigestString();
  27574.  
  27575. }
  27576.  
  27577. /*
  27578.     I use the 'chunk' method for processing files not because of
  27579.     limitations of my dll, but think what would happen if you
  27580.     tried to load an entire cd image into memory.
  27581. */
  27582. void DigestFile( char *szFName )
  27583. {
  27584.     FILE *file;
  27585.     void *lpData;
  27586.     long flen, mlen;
  27587.     MDxSum mdDataSum;
  27588.     MDxSum md4DataSum;
  27589.  
  27590.     // the 64 is for padding purposes
  27591.     lpData = malloc( READLEN + 64 );
  27592.     
  27593.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  27594.  
  27595.     file = fopen( szFName, "rb" );
  27596.     if( file == NULL )
  27597.     {
  27598.         printf("ERROR: File not found.\n");
  27599.         return;
  27600.     }
  27601.     
  27602.     MDxInit( &mdDataSum );
  27603.     MDxInit( &md4DataSum );
  27604.     
  27605.     fseek( file, 0, SEEK_END );
  27606.     //Get the file length
  27607.     flen = mlen = ftell( file );
  27608.     fseek( file, 0, SEEK_SET );
  27609.     
  27610.     // When it takes a while to process a large file,
  27611.     // remember that for each chunk it has to run 
  27612.     // through the main translation loop 16384 times!
  27613.         
  27614.     printf("Processing %ld byte file: .", flen );
  27615.     
  27616.     while( flen > READLEN )
  27617.     {
  27618.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27619.         {
  27620.             printf("READ ERROR!\n");
  27621.             return;
  27622.         }
  27623.         MD5Translate( lpData, READLEN, &mdDataSum );
  27624.         MD4Translate( lpData, READLEN, &md4DataSum );
  27625.         flen -= READLEN;
  27626.         printf(".");
  27627.     }
  27628.  
  27629.     if (fread( lpData, 1, flen, file ) != flen)
  27630.     {
  27631.         printf("READ ERROR!\n");
  27632.         return;
  27633.     }
  27634.     // This is why I added the new argument to MDxPad
  27635.     // So we can pass the length of the data AND the
  27636.     // Total length of the message
  27637.     // Also it now returns the # of padding bytes added,
  27638.     // this is for files that are an exact multiple of the chunk
  27639.     // length. (Otherwise the padding isn't Translated)
  27640.     flen += MDxPad( lpData, flen, mlen );
  27641.     MD5Translate( lpData, flen, &mdDataSum );    
  27642.     MD4Translate( lpData, flen, &md4DataSum );
  27643.  
  27644.     // New step necessary because of the 'chunking' method
  27645.     MDxFinalize( &mdDataSum );
  27646.     MDxFinalize( &md4DataSum );
  27647.     
  27648.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27649.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27650.     fclose(file);
  27651.         
  27652. }
  27653.  
  27654. void DigestString()
  27655. {
  27656.     
  27657.     //For our demo purposes, no strings bigger than 1024 :)
  27658.     unsigned char lpData[1024] = "";
  27659.     long len = 0;
  27660.     MDxSum mdDataSum;
  27661.  
  27662.     printf("Enter the string to digest: ");
  27663.     scanf("%s", &lpData );
  27664.     len = strlen(lpData);
  27665.     
  27666.     // Have to do this before the Padding...well...it's best anyway;)
  27667.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27668.     
  27669.     // For the strings, we're gonna pad and digest the string
  27670.     // in one pass.
  27671.     MDxInit( &mdDataSum );
  27672.     MDxPad( lpData, len, len );
  27673.     
  27674.     MD5Translate( lpData, len, &mdDataSum );
  27675.         // New step necessary because of the 'chunking' method
  27676.         MDxFinalize( &mdDataSum );
  27677.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27678.     
  27679.     MDxInit( &mdDataSum );
  27680.     MD4Translate( lpData, len, &mdDataSum );    
  27681.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27682.  
  27683.     return;
  27684. }
  27685.  
  27686.  
  27687. -------------- Include
  27688.  
  27689. #ifndef __windows_h__
  27690.         typedef unsigned long DWORD;
  27691.         #define STDCALL _stdcall
  27692. #endif
  27693.  
  27694. typedef struct 
  27695. {
  27696.     DWORD dwSum[4];
  27697. }MDxSum;
  27698.  
  27699. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  27700. void STDCALL MDxInit( MDxSum * );
  27701. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  27702. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  27703. const char * STDCALL MDxGetVersion();
  27704. void STDCALL MDxFinalize( MDxSum * );
  27705.  
  27706.  
  27707.  
  27708.  
  27709. #include "mdx.h"
  27710. #include <stdlib.h>
  27711. #include <stdio.h>
  27712. #include <string.h>
  27713.  
  27714. // READLEN % 64 must = 0
  27715. #define READLEN    1048576L // 2^20, 1MB
  27716.  
  27717. void DigestFile( char * );
  27718. void DigestString();
  27719.  
  27720. void main(int argc, char *argv[])
  27721. {
  27722.     printf("%s\n\n", MDxGetVersion());
  27723.  
  27724.     if( argc > 1 )
  27725.         DigestFile( argv[1] );
  27726.     else    
  27727.         DigestString();
  27728.  
  27729. }
  27730.  
  27731. /*
  27732.     I use the 'chunk' method for processing files not because of
  27733.     limitations of my dll, but think what would happen if you
  27734.     tried to load an entire cd image into memory.
  27735. */
  27736. void DigestFile( char *szFName )
  27737. {
  27738.     FILE *file;
  27739.     void *lpData;
  27740.     long flen, mlen;
  27741.     MDxSum mdDataSum;
  27742.     MDxSum md4DataSum;
  27743.  
  27744.     // the 64 is for padding purposes
  27745.     lpData = malloc( READLEN + 64 );
  27746.     
  27747.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  27748.  
  27749.     file = fopen( szFName, "rb" );
  27750.     if( file == NULL )
  27751.     {
  27752.         printf("ERROR: File not found.\n");
  27753.         return;
  27754.     }
  27755.     
  27756.     MDxInit( &mdDataSum );
  27757.     MDxInit( &md4DataSum );
  27758.     
  27759.     fseek( file, 0, SEEK_END );
  27760.     //Get the file length
  27761.     flen = mlen = ftell( file );
  27762.     fseek( file, 0, SEEK_SET );
  27763.     
  27764.     // When it takes a while to process a large file,
  27765.     // remember that for each chunk it has to run 
  27766.     // through the main translation loop 16384 times!
  27767.         
  27768.     printf("Processing %ld byte file: .", flen );
  27769.     
  27770.     while( flen > READLEN )
  27771.     {
  27772.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27773.         {
  27774.             printf("READ ERROR!\n");
  27775.             return;
  27776.         }
  27777.         MD5Translate( lpData, READLEN, &mdDataSum );
  27778.         MD4Translate( lpData, READLEN, &md4DataSum );
  27779.         flen -= READLEN;
  27780.         printf(".");
  27781.     }
  27782.  
  27783.     if (fread( lpData, 1, flen, file ) != flen)
  27784.     {
  27785.         printf("READ ERROR!\n");
  27786.         return;
  27787.     }
  27788.     // This is why I added the new argument to MDxPad
  27789.     // So we can pass the length of the data AND the
  27790.     // Total length of the message
  27791.     // Also it now returns the # of padding bytes added,
  27792.     // this is for files that are an exact multiple of the chunk
  27793.     // length. (Otherwise the padding isn't Translated)
  27794.     flen += MDxPad( lpData, flen, mlen );
  27795.     MD5Translate( lpData, flen, &mdDataSum );    
  27796.     MD4Translate( lpData, flen, &md4DataSum );
  27797.  
  27798.     // New step necessary because of the 'chunking' method
  27799.     MDxFinalize( &mdDataSum );
  27800.     MDxFinalize( &md4DataSum );
  27801.     
  27802.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27803.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27804.     fclose(file);
  27805.         
  27806. }
  27807.  
  27808. void DigestString()
  27809. {
  27810.     
  27811.     //For our demo purposes, no strings bigger than 1024 :)
  27812.     unsigned char lpData[1024] = "";
  27813.     long len = 0;
  27814.     MDxSum mdDataSum;
  27815.  
  27816.     printf("Enter the string to digest: ");
  27817.     scanf("%s", &lpData );
  27818.     len = strlen(lpData);
  27819.     
  27820.     // Have to do this before the Padding...well...it's best anyway;)
  27821.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27822.     
  27823.     // For the strings, we're gonna pad and digest the string
  27824.     // in one pass.
  27825.     MDxInit( &mdDataSum );
  27826.     MDxPad( lpData, len, len );
  27827.     
  27828.     MD5Translate( lpData, len, &mdDataSum );
  27829.         // New step necessary because of the 'chunking' method
  27830.         MDxFinalize( &mdDataSum );
  27831.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27832.     
  27833.     MDxInit( &mdDataSum );
  27834.     MD4Translate( lpData, len, &mdDataSum );    
  27835.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27836.  
  27837.     return;
  27838. }
  27839.  
  27840.  
  27841. -------------- Include
  27842.  
  27843. #ifndef __windows_h__
  27844.         typedef unsigned long DWORD;
  27845.         #define STDCALL _stdcall
  27846. #endif
  27847.  
  27848. typedef struct 
  27849. {
  27850.     DWORD dwSum[4];
  27851. }MDxSum;
  27852.  
  27853. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  27854. void STDCALL MDxInit( MDxSum * );
  27855. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  27856. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  27857. const char * STDCALL MDxGetVersion();
  27858. void STDCALL MDxFinalize( MDxSum * );
  27859.  
  27860.  
  27861.  
  27862.  
  27863. #include "mdx.h"
  27864. #include <stdlib.h>
  27865. #include <stdio.h>
  27866. #include <string.h>
  27867.  
  27868. // READLEN % 64 must = 0
  27869. #define READLEN    1048576L // 2^20, 1MB
  27870.  
  27871. void DigestFile( char * );
  27872. void DigestString();
  27873.  
  27874. void main(int argc, char *argv[])
  27875. {
  27876.     printf("%s\n\n", MDxGetVersion());
  27877.  
  27878.     if( argc > 1 )
  27879.         DigestFile( argv[1] );
  27880.     else    
  27881.         DigestString();
  27882.  
  27883. }
  27884.  
  27885. /*
  27886.     I use the 'chunk' method for processing files not because of
  27887.     limitations of my dll, but think what would happen if you
  27888.     tried to load an entire cd image into memory.
  27889. */
  27890. void DigestFile( char *szFName )
  27891. {
  27892.     FILE *file;
  27893.     void *lpData;
  27894.     long flen, mlen;
  27895.     MDxSum mdDataSum;
  27896.     MDxSum md4DataSum;
  27897.  
  27898.     // the 64 is for padding purposes
  27899.     lpData = malloc( READLEN + 64 );
  27900.     
  27901.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  27902.  
  27903.     file = fopen( szFName, "rb" );
  27904.     if( file == NULL )
  27905.     {
  27906.         printf("ERROR: File not found.\n");
  27907.         return;
  27908.     }
  27909.     
  27910.     MDxInit( &mdDataSum );
  27911.     MDxInit( &md4DataSum );
  27912.     
  27913.     fseek( file, 0, SEEK_END );
  27914.     //Get the file length
  27915.     flen = mlen = ftell( file );
  27916.     fseek( file, 0, SEEK_SET );
  27917.     
  27918.     // When it takes a while to process a large file,
  27919.     // remember that for each chunk it has to run 
  27920.     // through the main translation loop 16384 times!
  27921.         
  27922.     printf("Processing %ld byte file: .", flen );
  27923.     
  27924.     while( flen > READLEN )
  27925.     {
  27926.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  27927.         {
  27928.             printf("READ ERROR!\n");
  27929.             return;
  27930.         }
  27931.         MD5Translate( lpData, READLEN, &mdDataSum );
  27932.         MD4Translate( lpData, READLEN, &md4DataSum );
  27933.         flen -= READLEN;
  27934.         printf(".");
  27935.     }
  27936.  
  27937.     if (fread( lpData, 1, flen, file ) != flen)
  27938.     {
  27939.         printf("READ ERROR!\n");
  27940.         return;
  27941.     }
  27942.     // This is why I added the new argument to MDxPad
  27943.     // So we can pass the length of the data AND the
  27944.     // Total length of the message
  27945.     // Also it now returns the # of padding bytes added,
  27946.     // this is for files that are an exact multiple of the chunk
  27947.     // length. (Otherwise the padding isn't Translated)
  27948.     flen += MDxPad( lpData, flen, mlen );
  27949.     MD5Translate( lpData, flen, &mdDataSum );    
  27950.     MD4Translate( lpData, flen, &md4DataSum );
  27951.  
  27952.     // New step necessary because of the 'chunking' method
  27953.     MDxFinalize( &mdDataSum );
  27954.     MDxFinalize( &md4DataSum );
  27955.     
  27956.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  27957.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27958.     fclose(file);
  27959.         
  27960. }
  27961.  
  27962. void DigestString()
  27963. {
  27964.     
  27965.     //For our demo purposes, no strings bigger than 1024 :)
  27966.     unsigned char lpData[1024] = "";
  27967.     long len = 0;
  27968.     MDxSum mdDataSum;
  27969.  
  27970.     printf("Enter the string to digest: ");
  27971.     scanf("%s", &lpData );
  27972.     len = strlen(lpData);
  27973.     
  27974.     // Have to do this before the Padding...well...it's best anyway;)
  27975.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  27976.     
  27977.     // For the strings, we're gonna pad and digest the string
  27978.     // in one pass.
  27979.     MDxInit( &mdDataSum );
  27980.     MDxPad( lpData, len, len );
  27981.     
  27982.     MD5Translate( lpData, len, &mdDataSum );
  27983.         // New step necessary because of the 'chunking' method
  27984.         MDxFinalize( &mdDataSum );
  27985.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27986.     
  27987.     MDxInit( &mdDataSum );
  27988.     MD4Translate( lpData, len, &mdDataSum );    
  27989.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  27990.  
  27991.     return;
  27992. }
  27993.  
  27994.  
  27995. -------------- Include
  27996.  
  27997. #ifndef __windows_h__
  27998.         typedef unsigned long DWORD;
  27999.         #define STDCALL _stdcall
  28000. #endif
  28001.  
  28002. typedef struct 
  28003. {
  28004.     DWORD dwSum[4];
  28005. }MDxSum;
  28006.  
  28007. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28008. void STDCALL MDxInit( MDxSum * );
  28009. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28010. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28011. const char * STDCALL MDxGetVersion();
  28012. void STDCALL MDxFinalize( MDxSum * );
  28013.  
  28014.  
  28015.  
  28016. #include "mdx.h"
  28017. #include <stdlib.h>
  28018. #include <stdio.h>
  28019. #include <string.h>
  28020.  
  28021. // READLEN % 64 must = 0
  28022. #define READLEN    1048576L // 2^20, 1MB
  28023.  
  28024. void DigestFile( char * );
  28025. void DigestString();
  28026.  
  28027. void main(int argc, char *argv[])
  28028. {
  28029.     printf("%s\n\n", MDxGetVersion());
  28030.  
  28031.     if( argc > 1 )
  28032.         DigestFile( argv[1] );
  28033.     else    
  28034.         DigestString();
  28035.  
  28036. }
  28037.  
  28038. /*
  28039.     I use the 'chunk' method for processing files not because of
  28040.     limitations of my dll, but think what would happen if you
  28041.     tried to load an entire cd image into memory.
  28042. */
  28043. void DigestFile( char *szFName )
  28044. {
  28045.     FILE *file;
  28046.     void *lpData;
  28047.     long flen, mlen;
  28048.     MDxSum mdDataSum;
  28049.     MDxSum md4DataSum;
  28050.  
  28051.     // the 64 is for padding purposes
  28052.     lpData = malloc( READLEN + 64 );
  28053.     
  28054.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28055.  
  28056.     file = fopen( szFName, "rb" );
  28057.     if( file == NULL )
  28058.     {
  28059.         printf("ERROR: File not found.\n");
  28060.         return;
  28061.     }
  28062.     
  28063.     MDxInit( &mdDataSum );
  28064.     MDxInit( &md4DataSum );
  28065.     
  28066.     fseek( file, 0, SEEK_END );
  28067.     //Get the file length
  28068.     flen = mlen = ftell( file );
  28069.     fseek( file, 0, SEEK_SET );
  28070.     
  28071.     // When it takes a while to process a large file,
  28072.     // remember that for each chunk it has to run 
  28073.     // through the main translation loop 16384 times!
  28074.         
  28075.     printf("Processing %ld byte file: .", flen );
  28076.     
  28077.     while( flen > READLEN )
  28078.     {
  28079.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  28080.         {
  28081.             printf("READ ERROR!\n");
  28082.             return;
  28083.         }
  28084.         MD5Translate( lpData, READLEN, &mdDataSum );
  28085.         MD4Translate( lpData, READLEN, &md4DataSum );
  28086.         flen -= READLEN;
  28087.         printf(".");
  28088.     }
  28089.  
  28090.     if (fread( lpData, 1, flen, file ) != flen)
  28091.     {
  28092.         printf("READ ERROR!\n");
  28093.         return;
  28094.     }
  28095.     // This is why I added the new argument to MDxPad
  28096.     // So we can pass the length of the data AND the
  28097.     // Total length of the message
  28098.     // Also it now returns the # of padding bytes added,
  28099.     // this is for files that are an exact multiple of the chunk
  28100.     // length. (Otherwise the padding isn't Translated)
  28101.     flen += MDxPad( lpData, flen, mlen );
  28102.     MD5Translate( lpData, flen, &mdDataSum );    
  28103.     MD4Translate( lpData, flen, &md4DataSum );
  28104.  
  28105.     // New step necessary because of the 'chunking' method
  28106.     MDxFinalize( &mdDataSum );
  28107.     MDxFinalize( &md4DataSum );
  28108.     
  28109.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  28110.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28111.     fclose(file);
  28112.         
  28113. }
  28114.  
  28115. void DigestString()
  28116. {
  28117.     
  28118.     //For our demo purposes, no strings bigger than 1024 :)
  28119.     unsigned char lpData[1024] = "";
  28120.     long len = 0;
  28121.     MDxSum mdDataSum;
  28122.  
  28123.     printf("Enter the string to digest: ");
  28124.     scanf("%s", &lpData );
  28125.     len = strlen(lpData);
  28126.     
  28127.     // Have to do this before the Padding...well...it's best anyway;)
  28128.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  28129.     
  28130.     // For the strings, we're gonna pad and digest the string
  28131.     // in one pass.
  28132.     MDxInit( &mdDataSum );
  28133.     MDxPad( lpData, len, len );
  28134.     
  28135.     MD5Translate( lpData, len, &mdDataSum );
  28136.         // New step necessary because of the 'chunking' method
  28137.         MDxFinalize( &mdDataSum );
  28138.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28139.     
  28140.     MDxInit( &mdDataSum );
  28141.     MD4Translate( lpData, len, &mdDataSum );    
  28142.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28143.  
  28144.     return;
  28145. }
  28146.  
  28147.  
  28148. -------------- Include
  28149.  
  28150. #ifndef __windows_h__
  28151.         typedef unsigned long DWORD;
  28152.         #define STDCALL _stdcall
  28153. #endif
  28154.  
  28155. typedef struct 
  28156. {
  28157.     DWORD dwSum[4];
  28158. }MDxSum;
  28159.  
  28160. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28161. void STDCALL MDxInit( MDxSum * );
  28162. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28163. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28164. const char * STDCALL MDxGetVersion();
  28165. void STDCALL MDxFinalize( MDxSum * );
  28166.  
  28167.  
  28168.  
  28169. #include "mdx.h"
  28170. #include <stdlib.h>
  28171. #include <stdio.h>
  28172. #include <string.h>
  28173.  
  28174. // READLEN % 64 must = 0
  28175. #define READLEN    1048576L // 2^20, 1MB
  28176.  
  28177. void DigestFile( char * );
  28178. void DigestString();
  28179.  
  28180. void main(int argc, char *argv[])
  28181. {
  28182.     printf("%s\n\n", MDxGetVersion());
  28183.  
  28184.     if( argc > 1 )
  28185.         DigestFile( argv[1] );
  28186.     else    
  28187.         DigestString();
  28188.  
  28189. }
  28190.  
  28191. /*
  28192.     I use the 'chunk' method for processing files not because of
  28193.     limitations of my dll, but think what would happen if you
  28194.     tried to load an entire cd image into memory.
  28195. */
  28196. void DigestFile( char *szFName )
  28197. {
  28198.     FILE *file;
  28199.     void *lpData;
  28200.     long flen, mlen;
  28201.     MDxSum mdDataSum;
  28202.     MDxSum md4DataSum;
  28203.  
  28204.     // the 64 is for padding purposes
  28205.     lpData = malloc( READLEN + 64 );
  28206.     
  28207.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28208.  
  28209.     file = fopen( szFName, "rb" );
  28210.     if( file == NULL )
  28211.     {
  28212.         printf("ERROR: File not found.\n");
  28213.         return;
  28214.     }
  28215.     
  28216.     MDxInit( &mdDataSum );
  28217.     MDxInit( &md4DataSum );
  28218.     
  28219.     fseek( file, 0, SEEK_END );
  28220.     //Get the file length
  28221.     flen = mlen = ftell( file );
  28222.     fseek( file, 0, SEEK_SET );
  28223.     
  28224.     // When it takes a while to process a large file,
  28225.     // remember that for each chunk it has to run 
  28226.     // through the main translation loop 16384 times!
  28227.         
  28228.     printf("Processing %ld byte file: .", flen );
  28229.     
  28230.     while( flen > READLEN )
  28231.     {
  28232.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  28233.         {
  28234.             printf("READ ERROR!\n");
  28235.             return;
  28236.         }
  28237.         MD5Translate( lpData, READLEN, &mdDataSum );
  28238.         MD4Translate( lpData, READLEN, &md4DataSum );
  28239.         flen -= READLEN;
  28240.         printf(".");
  28241.     }
  28242.  
  28243.     if (fread( lpData, 1, flen, file ) != flen)
  28244.     {
  28245.         printf("READ ERROR!\n");
  28246.         return;
  28247.     }
  28248.     // This is why I added the new argument to MDxPad
  28249.     // So we can pass the length of the data AND the
  28250.     // Total length of the message
  28251.     // Also it now returns the # of padding bytes added,
  28252.     // this is for files that are an exact multiple of the chunk
  28253.     // length. (Otherwise the padding isn't Translated)
  28254.     flen += MDxPad( lpData, flen, mlen );
  28255.     MD5Translate( lpData, flen, &mdDataSum );    
  28256.     MD4Translate( lpData, flen, &md4DataSum );
  28257.  
  28258.     // New step necessary because of the 'chunking' method
  28259.     MDxFinalize( &mdDataSum );
  28260.     MDxFinalize( &md4DataSum );
  28261.     
  28262.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  28263.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28264.     fclose(file);
  28265.         
  28266. }
  28267.  
  28268. void DigestString()
  28269. {
  28270.     
  28271.     //For our demo purposes, no strings bigger than 1024 :)
  28272.     unsigned char lpData[1024] = "";
  28273.     long len = 0;
  28274.     MDxSum mdDataSum;
  28275.  
  28276.     printf("Enter the string to digest: ");
  28277.     scanf("%s", &lpData );
  28278.     len = strlen(lpData);
  28279.     
  28280.     // Have to do this before the Padding...well...it's best anyway;)
  28281.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  28282.     
  28283.     // For the strings, we're gonna pad and digest the string
  28284.     // in one pass.
  28285.     MDxInit( &mdDataSum );
  28286.     MDxPad( lpData, len, len );
  28287.     
  28288.     MD5Translate( lpData, len, &mdDataSum );
  28289.         // New step necessary because of the 'chunking' method
  28290.         MDxFinalize( &mdDataSum );
  28291.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28292.     
  28293.     MDxInit( &mdDataSum );
  28294.     MD4Translate( lpData, len, &mdDataSum );    
  28295.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28296.  
  28297.     return;
  28298. }
  28299.  
  28300.  
  28301. -------------- Include
  28302.  
  28303. #ifndef __windows_h__
  28304.         typedef unsigned long DWORD;
  28305.         #define STDCALL _stdcall
  28306. #endif
  28307.  
  28308. typedef struct 
  28309. {
  28310.     DWORD dwSum[4];
  28311. }MDxSum;
  28312.  
  28313. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28314. void STDCALL MDxInit( MDxSum * );
  28315. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28316. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28317. const char * STDCALL MDxGetVersion();
  28318. void STDCALL MDxFinalize( MDxSum * );
  28319.  
  28320.  
  28321.  
  28322.  
  28323. #include "mdx.h"
  28324. #include <stdlib.h>
  28325. #include <stdio.h>
  28326. #include <string.h>
  28327.  
  28328. // READLEN % 64 must = 0
  28329. #define READLEN    1048576L // 2^20, 1MB
  28330.  
  28331. void DigestFile( char * );
  28332. void DigestString();
  28333.  
  28334. void main(int argc, char *argv[])
  28335. {
  28336.     printf("%s\n\n", MDxGetVersion());
  28337.  
  28338.     if( argc > 1 )
  28339.         DigestFile( argv[1] );
  28340.     else    
  28341.         DigestString();
  28342.  
  28343. }
  28344.  
  28345. /*
  28346.     I use the 'chunk' method for processing files not because of
  28347.     limitations of my dll, but think what would happen if you
  28348.     tried to load an entire cd image into memory.
  28349. */
  28350. void DigestFile( char *szFName )
  28351. {
  28352.     FILE *file;
  28353.     void *lpData;
  28354.     long flen, mlen;
  28355.     MDxSum mdDataSum;
  28356.     MDxSum md4DataSum;
  28357.  
  28358.     // the 64 is for padding purposes
  28359.     lpData = malloc( READLEN + 64 );
  28360.     
  28361.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28362.  
  28363.     file = fopen( szFName, "rb" );
  28364.     if( file == NULL )
  28365.     {
  28366.         printf("ERROR: File not found.\n");
  28367.         return;
  28368.     }
  28369.     
  28370.     MDxInit( &mdDataSum );
  28371.     MDxInit( &md4DataSum );
  28372.     
  28373.     fseek( file, 0, SEEK_END );
  28374.     //Get the file length
  28375.     flen = mlen = ftell( file );
  28376.     fseek( file, 0, SEEK_SET );
  28377.     
  28378.     // When it takes a while to process a large file,
  28379.     // remember that for each chunk it has to run 
  28380.     // through the main translation loop 16384 times!
  28381.         
  28382.     printf("Processing %ld byte file: .", flen );
  28383.     
  28384.     while( flen > READLEN )
  28385.     {
  28386.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  28387.         {
  28388.             printf("READ ERROR!\n");
  28389.             return;
  28390.         }
  28391.         MD5Translate( lpData, READLEN, &mdDataSum );
  28392.         MD4Translate( lpData, READLEN, &md4DataSum );
  28393.         flen -= READLEN;
  28394.         printf(".");
  28395.     }
  28396.  
  28397.     if (fread( lpData, 1, flen, file ) != flen)
  28398.     {
  28399.         printf("READ ERROR!\n");
  28400.         return;
  28401.     }
  28402.     // This is why I added the new argument to MDxPad
  28403.     // So we can pass the length of the data AND the
  28404.     // Total length of the message
  28405.     // Also it now returns the # of padding bytes added,
  28406.     // this is for files that are an exact multiple of the chunk
  28407.     // length. (Otherwise the padding isn't Translated)
  28408.     flen += MDxPad( lpData, flen, mlen );
  28409.     MD5Translate( lpData, flen, &mdDataSum );    
  28410.     MD4Translate( lpData, flen, &md4DataSum );
  28411.  
  28412.     // New step necessary because of the 'chunking' method
  28413.     MDxFinalize( &mdDataSum );
  28414.     MDxFinalize( &md4DataSum );
  28415.     
  28416.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  28417.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28418.     fclose(file);
  28419.         
  28420. }
  28421.  
  28422. void DigestString()
  28423. {
  28424.     
  28425.     //For our demo purposes, no strings bigger than 1024 :)
  28426.     unsigned char lpData[1024] = "";
  28427.     long len = 0;
  28428.     MDxSum mdDataSum;
  28429.  
  28430.     printf("Enter the string to digest: ");
  28431.     scanf("%s", &lpData );
  28432.     len = strlen(lpData);
  28433.     
  28434.     // Have to do this before the Padding...well...it's best anyway;)
  28435.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  28436.     
  28437.     // For the strings, we're gonna pad and digest the string
  28438.     // in one pass.
  28439.     MDxInit( &mdDataSum );
  28440.     MDxPad( lpData, len, len );
  28441.     
  28442.     MD5Translate( lpData, len, &mdDataSum );
  28443.         // New step necessary because of the 'chunking' method
  28444.         MDxFinalize( &mdDataSum );
  28445.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28446.     
  28447.     MDxInit( &mdDataSum );
  28448.     MD4Translate( lpData, len, &mdDataSum );    
  28449.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28450.  
  28451.     return;
  28452. }
  28453.  
  28454.  
  28455. -------------- Include
  28456.  
  28457. #ifndef __windows_h__
  28458.         typedef unsigned long DWORD;
  28459.         #define STDCALL _stdcall
  28460. #endif
  28461.  
  28462. typedef struct 
  28463. {
  28464.     DWORD dwSum[4];
  28465. }MDxSum;
  28466.  
  28467. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28468. void STDCALL MDxInit( MDxSum * );
  28469. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28470. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28471. const char * STDCALL MDxGetVersion();
  28472. void STDCALL MDxFinalize( MDxSum * );
  28473.  
  28474.  
  28475.  
  28476. #include "mdx.h"
  28477. #include <stdlib.h>
  28478. #include <stdio.h>
  28479. #include <string.h>
  28480.  
  28481. // READLEN % 64 must = 0
  28482. #define READLEN    1048576L // 2^20, 1MB
  28483.  
  28484. void DigestFile( char * );
  28485. void DigestString();
  28486.  
  28487. void main(int argc, char *argv[])
  28488. {
  28489.     printf("%s\n\n", MDxGetVersion());
  28490.  
  28491.     if( argc > 1 )
  28492.         DigestFile( argv[1] );
  28493.     else    
  28494.         DigestString();
  28495.  
  28496. }
  28497.  
  28498. /*
  28499.     I use the 'chunk' method for processing files not because of
  28500.     limitations of my dll, but think what would happen if you
  28501.     tried to load an entire cd image into memory.
  28502. */
  28503. void DigestFile( char *szFName )
  28504. {
  28505.     FILE *file;
  28506.     void *lpData;
  28507.     long flen, mlen;
  28508.     MDxSum mdDataSum;
  28509.     MDxSum md4DataSum;
  28510.  
  28511.     // the 64 is for padding purposes
  28512.     lpData = malloc( READLEN + 64 );
  28513.     
  28514.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28515.  
  28516.     file = fopen( szFName, "rb" );
  28517.     if( file == NULL )
  28518.     {
  28519.         printf("ERROR: File not found.\n");
  28520.         return;
  28521.     }
  28522.     
  28523.     MDxInit( &mdDataSum );
  28524.     MDxInit( &md4DataSum );
  28525.     
  28526.     fseek( file, 0, SEEK_END );
  28527.     //Get the file length
  28528.     flen = mlen = ftell( file );
  28529.     fseek( file, 0, SEEK_SET );
  28530.     
  28531.     // When it takes a while to process a large file,
  28532.     // remember that for each chunk it has to run 
  28533.     // through the main translation loop 16384 times!
  28534.         
  28535.     printf("Processing %ld byte file: .", flen );
  28536.     
  28537.     while( flen > READLEN )
  28538.     {
  28539.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  28540.         {
  28541.             printf("READ ERROR!\n");
  28542.             return;
  28543.         }
  28544.         MD5Translate( lpData, READLEN, &mdDataSum );
  28545.         MD4Translate( lpData, READLEN, &md4DataSum );
  28546.         flen -= READLEN;
  28547.         printf(".");
  28548.     }
  28549.  
  28550.     if (fread( lpData, 1, flen, file ) != flen)
  28551.     {
  28552.         printf("READ ERROR!\n");
  28553.         return;
  28554.     }
  28555.     // This is why I added the new argument to MDxPad
  28556.     // So we can pass the length of the data AND the
  28557.     // Total length of the message
  28558.     // Also it now returns the # of padding bytes added,
  28559.     // this is for files that are an exact multiple of the chunk
  28560.     // length. (Otherwise the padding isn't Translated)
  28561.     flen += MDxPad( lpData, flen, mlen );
  28562.     MD5Translate( lpData, flen, &mdDataSum );    
  28563.     MD4Translate( lpData, flen, &md4DataSum );
  28564.  
  28565.     // New step necessary because of the 'chunking' method
  28566.     MDxFinalize( &mdDataSum );
  28567.     MDxFinalize( &md4DataSum );
  28568.     
  28569.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  28570.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28571.     fclose(file);
  28572.         
  28573. }
  28574.  
  28575. void DigestString()
  28576. {
  28577.     
  28578.     //For our demo purposes, no strings bigger than 1024 :)
  28579.     unsigned char lpData[1024] = "";
  28580.     long len = 0;
  28581.     MDxSum mdDataSum;
  28582.  
  28583.     printf("Enter the string to digest: ");
  28584.     scanf("%s", &lpData );
  28585.     len = strlen(lpData);
  28586.     
  28587.     // Have to do this before the Padding...well...it's best anyway;)
  28588.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  28589.     
  28590.     // For the strings, we're gonna pad and digest the string
  28591.     // in one pass.
  28592.     MDxInit( &mdDataSum );
  28593.     MDxPad( lpData, len, len );
  28594.     
  28595.     MD5Translate( lpData, len, &mdDataSum );
  28596.         // New step necessary because of the 'chunking' method
  28597.         MDxFinalize( &mdDataSum );
  28598.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28599.     
  28600.     MDxInit( &mdDataSum );
  28601.     MD4Translate( lpData, len, &mdDataSum );    
  28602.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28603.  
  28604.     return;
  28605. }
  28606.  
  28607.  
  28608. -------------- Include
  28609.  
  28610. #ifndef __windows_h__
  28611.         typedef unsigned long DWORD;
  28612.         #define STDCALL _stdcall
  28613. #endif
  28614.  
  28615. typedef struct 
  28616. {
  28617.     DWORD dwSum[4];
  28618. }MDxSum;
  28619.  
  28620. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28621. void STDCALL MDxInit( MDxSum * );
  28622. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28623. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28624. const char * STDCALL MDxGetVersion();
  28625. void STDCALL MDxFinalize( MDxSum * );
  28626.  
  28627.  
  28628.  
  28629.  
  28630. #include "mdx.h"
  28631. #include <stdlib.h>
  28632. #include <stdio.h>
  28633. #include <string.h>
  28634.  
  28635. // READLEN % 64 must = 0
  28636. #define READLEN    1048576L // 2^20, 1MB
  28637.  
  28638. void DigestFile( char * );
  28639. void DigestString();
  28640.  
  28641. void main(int argc, char *argv[])
  28642. {
  28643.     printf("%s\n\n", MDxGetVersion());
  28644.  
  28645.     if( argc > 1 )
  28646.         DigestFile( argv[1] );
  28647.     else    
  28648.         DigestString();
  28649.  
  28650. }
  28651.  
  28652. /*
  28653.     I use the 'chunk' method for processing files not because of
  28654.     limitations of my dll, but think what would happen if you
  28655.     tried to load an entire cd image into memory.
  28656. */
  28657. void DigestFile( char *szFName )
  28658. {
  28659.     FILE *file;
  28660.     void *lpData;
  28661.     long flen, mlen;
  28662.     MDxSum mdDataSum;
  28663.     MDxSum md4DataSum;
  28664.  
  28665.     // the 64 is for padding purposes
  28666.     lpData = malloc( READLEN + 64 );
  28667.     
  28668.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28669.  
  28670.     file = fopen( szFName, "rb" );
  28671.     if( file == NULL )
  28672.     {
  28673.         printf("ERROR: File not found.\n");
  28674.         return;
  28675.     }
  28676.     
  28677.     MDxInit( &mdDataSum );
  28678.     MDxInit( &md4DataSum );
  28679.     
  28680.     fseek( file, 0, SEEK_END );
  28681.     //Get the file length
  28682.     flen = mlen = ftell( file );
  28683.     fseek( file, 0, SEEK_SET );
  28684.     
  28685.     // When it takes a while to process a large file,
  28686.     // remember that for each chunk it has to run 
  28687.     // through the main translation loop 16384 times!
  28688.         
  28689.     printf("Processing %ld byte file: .", flen );
  28690.     
  28691.     while( flen > READLEN )
  28692.     {
  28693.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  28694.         {
  28695.             printf("READ ERROR!\n");
  28696.             return;
  28697.         }
  28698.         MD5Translate( lpData, READLEN, &mdDataSum );
  28699.         MD4Translate( lpData, READLEN, &md4DataSum );
  28700.         flen -= READLEN;
  28701.         printf(".");
  28702.     }
  28703.  
  28704.     if (fread( lpData, 1, flen, file ) != flen)
  28705.     {
  28706.         printf("READ ERROR!\n");
  28707.         return;
  28708.     }
  28709.     // This is why I added the new argument to MDxPad
  28710.     // So we can pass the length of the data AND the
  28711.     // Total length of the message
  28712.     // Also it now returns the # of padding bytes added,
  28713.     // this is for files that are an exact multiple of the chunk
  28714.     // length. (Otherwise the padding isn't Translated)
  28715.     flen += MDxPad( lpData, flen, mlen );
  28716.     MD5Translate( lpData, flen, &mdDataSum );    
  28717.     MD4Translate( lpData, flen, &md4DataSum );
  28718.  
  28719.     // New step necessary because of the 'chunking' method
  28720.     MDxFinalize( &mdDataSum );
  28721.     MDxFinalize( &md4DataSum );
  28722.     
  28723.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  28724.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28725.     fclose(file);
  28726.         
  28727. }
  28728.  
  28729. void DigestString()
  28730. {
  28731.     
  28732.     //For our demo purposes, no strings bigger than 1024 :)
  28733.     unsigned char lpData[1024] = "";
  28734.     long len = 0;
  28735.     MDxSum mdDataSum;
  28736.  
  28737.     printf("Enter the string to digest: ");
  28738.     scanf("%s", &lpData );
  28739.     len = strlen(lpData);
  28740.     
  28741.     // Have to do this before the Padding...well...it's best anyway;)
  28742.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  28743.     
  28744.     // For the strings, we're gonna pad and digest the string
  28745.     // in one pass.
  28746.     MDxInit( &mdDataSum );
  28747.     MDxPad( lpData, len, len );
  28748.     
  28749.     MD5Translate( lpData, len, &mdDataSum );
  28750.         // New step necessary because of the 'chunking' method
  28751.         MDxFinalize( &mdDataSum );
  28752.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28753.     
  28754.     MDxInit( &mdDataSum );
  28755.     MD4Translate( lpData, len, &mdDataSum );    
  28756.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28757.  
  28758.     return;
  28759. }
  28760.  
  28761.  
  28762. -------------- Include
  28763.  
  28764. #ifndef __windows_h__
  28765.         typedef unsigned long DWORD;
  28766.         #define STDCALL _stdcall
  28767. #endif
  28768.  
  28769. typedef struct 
  28770. {
  28771.     DWORD dwSum[4];
  28772. }MDxSum;
  28773.  
  28774. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28775. void STDCALL MDxInit( MDxSum * );
  28776. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28777. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28778. const char * STDCALL MDxGetVersion();
  28779. void STDCALL MDxFinalize( MDxSum * );
  28780.  
  28781.  
  28782.  
  28783.  
  28784. #include "mdx.h"
  28785. #include <stdlib.h>
  28786. #include <stdio.h>
  28787. #include <string.h>
  28788.  
  28789. // READLEN % 64 must = 0
  28790. #define READLEN    1048576L // 2^20, 1MB
  28791.  
  28792. void DigestFile( char * );
  28793. void DigestString();
  28794.  
  28795. void main(int argc, char *argv[])
  28796. {
  28797.     printf("%s\n\n", MDxGetVersion());
  28798.  
  28799.     if( argc > 1 )
  28800.         DigestFile( argv[1] );
  28801.     else    
  28802.         DigestString();
  28803.  
  28804. }
  28805.  
  28806. /*
  28807.     I use the 'chunk' method for processing files not because of
  28808.     limitations of my dll, but think what would happen if you
  28809.     tried to load an entire cd image into memory.
  28810. */
  28811. void DigestFile( char *szFName )
  28812. {
  28813.     FILE *file;
  28814.     void *lpData;
  28815.     long flen, mlen;
  28816.     MDxSum mdDataSum;
  28817.     MDxSum md4DataSum;
  28818.  
  28819.     // the 64 is for padding purposes
  28820.     lpData = malloc( READLEN + 64 );
  28821.     
  28822.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28823.  
  28824.     file = fopen( szFName, "rb" );
  28825.     if( file == NULL )
  28826.     {
  28827.         printf("ERROR: File not found.\n");
  28828.         return;
  28829.     }
  28830.     
  28831.     MDxInit( &mdDataSum );
  28832.     MDxInit( &md4DataSum );
  28833.     
  28834.     fseek( file, 0, SEEK_END );
  28835.     //Get the file length
  28836.     flen = mlen = ftell( file );
  28837.     fseek( file, 0, SEEK_SET );
  28838.     
  28839.     // When it takes a while to process a large file,
  28840.     // remember that for each chunk it has to run 
  28841.     // through the main translation loop 16384 times!
  28842.         
  28843.     printf("Processing %ld byte file: .", flen );
  28844.     
  28845.     while( flen > READLEN )
  28846.     {
  28847.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  28848.         {
  28849.             printf("READ ERROR!\n");
  28850.             return;
  28851.         }
  28852.         MD5Translate( lpData, READLEN, &mdDataSum );
  28853.         MD4Translate( lpData, READLEN, &md4DataSum );
  28854.         flen -= READLEN;
  28855.         printf(".");
  28856.     }
  28857.  
  28858.     if (fread( lpData, 1, flen, file ) != flen)
  28859.     {
  28860.         printf("READ ERROR!\n");
  28861.         return;
  28862.     }
  28863.     // This is why I added the new argument to MDxPad
  28864.     // So we can pass the length of the data AND the
  28865.     // Total length of the message
  28866.     // Also it now returns the # of padding bytes added,
  28867.     // this is for files that are an exact multiple of the chunk
  28868.     // length. (Otherwise the padding isn't Translated)
  28869.     flen += MDxPad( lpData, flen, mlen );
  28870.     MD5Translate( lpData, flen, &mdDataSum );    
  28871.     MD4Translate( lpData, flen, &md4DataSum );
  28872.  
  28873.     // New step necessary because of the 'chunking' method
  28874.     MDxFinalize( &mdDataSum );
  28875.     MDxFinalize( &md4DataSum );
  28876.     
  28877.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  28878.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28879.     fclose(file);
  28880.         
  28881. }
  28882.  
  28883. void DigestString()
  28884. {
  28885.     
  28886.     //For our demo purposes, no strings bigger than 1024 :)
  28887.     unsigned char lpData[1024] = "";
  28888.     long len = 0;
  28889.     MDxSum mdDataSum;
  28890.  
  28891.     printf("Enter the string to digest: ");
  28892.     scanf("%s", &lpData );
  28893.     len = strlen(lpData);
  28894.     
  28895.     // Have to do this before the Padding...well...it's best anyway;)
  28896.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  28897.     
  28898.     // For the strings, we're gonna pad and digest the string
  28899.     // in one pass.
  28900.     MDxInit( &mdDataSum );
  28901.     MDxPad( lpData, len, len );
  28902.     
  28903.     MD5Translate( lpData, len, &mdDataSum );
  28904.         // New step necessary because of the 'chunking' method
  28905.         MDxFinalize( &mdDataSum );
  28906.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28907.     
  28908.     MDxInit( &mdDataSum );
  28909.     MD4Translate( lpData, len, &mdDataSum );    
  28910.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  28911.  
  28912.     return;
  28913. }
  28914.  
  28915.  
  28916. -------------- Include
  28917.  
  28918. #ifndef __windows_h__
  28919.         typedef unsigned long DWORD;
  28920.         #define STDCALL _stdcall
  28921. #endif
  28922.  
  28923. typedef struct 
  28924. {
  28925.     DWORD dwSum[4];
  28926. }MDxSum;
  28927.  
  28928. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  28929. void STDCALL MDxInit( MDxSum * );
  28930. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  28931. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  28932. const char * STDCALL MDxGetVersion();
  28933. void STDCALL MDxFinalize( MDxSum * );
  28934.  
  28935.  
  28936.  
  28937. #include "mdx.h"
  28938. #include <stdlib.h>
  28939. #include <stdio.h>
  28940. #include <string.h>
  28941.  
  28942. // READLEN % 64 must = 0
  28943. #define READLEN    1048576L // 2^20, 1MB
  28944.  
  28945. void DigestFile( char * );
  28946. void DigestString();
  28947.  
  28948. void main(int argc, char *argv[])
  28949. {
  28950.     printf("%s\n\n", MDxGetVersion());
  28951.  
  28952.     if( argc > 1 )
  28953.         DigestFile( argv[1] );
  28954.     else    
  28955.         DigestString();
  28956.  
  28957. }
  28958.  
  28959. /*
  28960.     I use the 'chunk' method for processing files not because of
  28961.     limitations of my dll, but think what would happen if you
  28962.     tried to load an entire cd image into memory.
  28963. */
  28964. void DigestFile( char *szFName )
  28965. {
  28966.     FILE *file;
  28967.     void *lpData;
  28968.     long flen, mlen;
  28969.     MDxSum mdDataSum;
  28970.     MDxSum md4DataSum;
  28971.  
  28972.     // the 64 is for padding purposes
  28973.     lpData = malloc( READLEN + 64 );
  28974.     
  28975.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  28976.  
  28977.     file = fopen( szFName, "rb" );
  28978.     if( file == NULL )
  28979.     {
  28980.         printf("ERROR: File not found.\n");
  28981.         return;
  28982.     }
  28983.     
  28984.     MDxInit( &mdDataSum );
  28985.     MDxInit( &md4DataSum );
  28986.     
  28987.     fseek( file, 0, SEEK_END );
  28988.     //Get the file length
  28989.     flen = mlen = ftell( file );
  28990.     fseek( file, 0, SEEK_SET );
  28991.     
  28992.     // When it takes a while to process a large file,
  28993.     // remember that for each chunk it has to run 
  28994.     // through the main translation loop 16384 times!
  28995.         
  28996.     printf("Processing %ld byte file: .", flen );
  28997.     
  28998.     while( flen > READLEN )
  28999.     {
  29000.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29001.         {
  29002.             printf("READ ERROR!\n");
  29003.             return;
  29004.         }
  29005.         MD5Translate( lpData, READLEN, &mdDataSum );
  29006.         MD4Translate( lpData, READLEN, &md4DataSum );
  29007.         flen -= READLEN;
  29008.         printf(".");
  29009.     }
  29010.  
  29011.     if (fread( lpData, 1, flen, file ) != flen)
  29012.     {
  29013.         printf("READ ERROR!\n");
  29014.         return;
  29015.     }
  29016.     // This is why I added the new argument to MDxPad
  29017.     // So we can pass the length of the data AND the
  29018.     // Total length of the message
  29019.     // Also it now returns the # of padding bytes added,
  29020.     // this is for files that are an exact multiple of the chunk
  29021.     // length. (Otherwise the padding isn't Translated)
  29022.     flen += MDxPad( lpData, flen, mlen );
  29023.     MD5Translate( lpData, flen, &mdDataSum );    
  29024.     MD4Translate( lpData, flen, &md4DataSum );
  29025.  
  29026.     // New step necessary because of the 'chunking' method
  29027.     MDxFinalize( &mdDataSum );
  29028.     MDxFinalize( &md4DataSum );
  29029.     
  29030.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29031.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29032.     fclose(file);
  29033.         
  29034. }
  29035.  
  29036. void DigestString()
  29037. {
  29038.     
  29039.     //For our demo purposes, no strings bigger than 1024 :)
  29040.     unsigned char lpData[1024] = "";
  29041.     long len = 0;
  29042.     MDxSum mdDataSum;
  29043.  
  29044.     printf("Enter the string to digest: ");
  29045.     scanf("%s", &lpData );
  29046.     len = strlen(lpData);
  29047.     
  29048.     // Have to do this before the Padding...well...it's best anyway;)
  29049.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29050.     
  29051.     // For the strings, we're gonna pad and digest the string
  29052.     // in one pass.
  29053.     MDxInit( &mdDataSum );
  29054.     MDxPad( lpData, len, len );
  29055.     
  29056.     MD5Translate( lpData, len, &mdDataSum );
  29057.         // New step necessary because of the 'chunking' method
  29058.         MDxFinalize( &mdDataSum );
  29059.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29060.     
  29061.     MDxInit( &mdDataSum );
  29062.     MD4Translate( lpData, len, &mdDataSum );    
  29063.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29064.  
  29065.     return;
  29066. }
  29067.  
  29068.  
  29069. -------------- Include
  29070.  
  29071. #ifndef __windows_h__
  29072.         typedef unsigned long DWORD;
  29073.         #define STDCALL _stdcall
  29074. #endif
  29075.  
  29076. typedef struct 
  29077. {
  29078.     DWORD dwSum[4];
  29079. }MDxSum;
  29080.  
  29081. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29082. void STDCALL MDxInit( MDxSum * );
  29083. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29084. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  29085. const char * STDCALL MDxGetVersion();
  29086. void STDCALL MDxFinalize( MDxSum * );
  29087.  
  29088.  
  29089. #include "mdx.h"
  29090. #include <stdlib.h>
  29091. #include <stdio.h>
  29092. #include <string.h>
  29093.  
  29094. // READLEN % 64 must = 0
  29095. #define READLEN    1048576L // 2^20, 1MB
  29096.  
  29097. void DigestFile( char * );
  29098. void DigestString();
  29099.  
  29100. void main(int argc, char *argv[])
  29101. {
  29102.     printf("%s\n\n", MDxGetVersion());
  29103.  
  29104.     if( argc > 1 )
  29105.         DigestFile( argv[1] );
  29106.     else    
  29107.         DigestString();
  29108.  
  29109. }
  29110.  
  29111. /*
  29112.     I use the 'chunk' method for processing files not because of
  29113.     limitations of my dll, but think what would happen if you
  29114.     tried to load an entire cd image into memory.
  29115. */
  29116. void DigestFile( char *szFName )
  29117. {
  29118.     FILE *file;
  29119.     void *lpData;
  29120.     long flen, mlen;
  29121.     MDxSum mdDataSum;
  29122.     MDxSum md4DataSum;
  29123.  
  29124.     // the 64 is for padding purposes
  29125.     lpData = malloc( READLEN + 64 );
  29126.     
  29127.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  29128.  
  29129.     file = fopen( szFName, "rb" );
  29130.     if( file == NULL )
  29131.     {
  29132.         printf("ERROR: File not found.\n");
  29133.         return;
  29134.     }
  29135.     
  29136.     MDxInit( &mdDataSum );
  29137.     MDxInit( &md4DataSum );
  29138.     
  29139.     fseek( file, 0, SEEK_END );
  29140.     //Get the file length
  29141.     flen = mlen = ftell( file );
  29142.     fseek( file, 0, SEEK_SET );
  29143.     
  29144.     // When it takes a while to process a large file,
  29145.     // remember that for each chunk it has to run 
  29146.     // through the main translation loop 16384 times!
  29147.         
  29148.     printf("Processing %ld byte file: .", flen );
  29149.     
  29150.     while( flen > READLEN )
  29151.     {
  29152.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29153.         {
  29154.             printf("READ ERROR!\n");
  29155.             return;
  29156.         }
  29157.         MD5Translate( lpData, READLEN, &mdDataSum );
  29158.         MD4Translate( lpData, READLEN, &md4DataSum );
  29159.         flen -= READLEN;
  29160.         printf(".");
  29161.     }
  29162.  
  29163.     if (fread( lpData, 1, flen, file ) != flen)
  29164.     {
  29165.         printf("READ ERROR!\n");
  29166.         return;
  29167.     }
  29168.     // This is why I added the new argument to MDxPad
  29169.     // So we can pass the length of the data AND the
  29170.     // Total length of the message
  29171.     // Also it now returns the # of padding bytes added,
  29172.     // this is for files that are an exact multiple of the chunk
  29173.     // length. (Otherwise the padding isn't Translated)
  29174.     flen += MDxPad( lpData, flen, mlen );
  29175.     MD5Translate( lpData, flen, &mdDataSum );    
  29176.     MD4Translate( lpData, flen, &md4DataSum );
  29177.  
  29178.     // New step necessary because of the 'chunking' method
  29179.     MDxFinalize( &mdDataSum );
  29180.     MDxFinalize( &md4DataSum );
  29181.     
  29182.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29183.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29184.     fclose(file);
  29185.         
  29186. }
  29187.  
  29188. void DigestString()
  29189. {
  29190.     
  29191.     //For our demo purposes, no strings bigger than 1024 :)
  29192.     unsigned char lpData[1024] = "";
  29193.     long len = 0;
  29194.     MDxSum mdDataSum;
  29195.  
  29196.     printf("Enter the string to digest: ");
  29197.     scanf("%s", &lpData );
  29198.     len = strlen(lpData);
  29199.     
  29200.     // Have to do this before the Padding...well...it's best anyway;)
  29201.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29202.     
  29203.     // For the strings, we're gonna pad and digest the string
  29204.     // in one pass.
  29205.     MDxInit( &mdDataSum );
  29206.     MDxPad( lpData, len, len );
  29207.     
  29208.     MD5Translate( lpData, len, &mdDataSum );
  29209.         // New step necessary because of the 'chunking' method
  29210.         MDxFinalize( &mdDataSum );
  29211.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29212.     
  29213.     MDxInit( &mdDataSum );
  29214.     MD4Translate( lpData, len, &mdDataSum );    
  29215.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29216.  
  29217.     return;
  29218. }
  29219.  
  29220.  
  29221. -------------- Include
  29222.  
  29223. #ifndef __windows_h__
  29224.         typedef unsigned long DWORD;
  29225.         #define STDCALL _stdcall
  29226. #endif
  29227.  
  29228. typedef struct 
  29229. {
  29230.     DWORD dwSum[4];
  29231. }MDxSum;
  29232.  
  29233. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29234. void STDCALL MDxInit( MDxSum * );
  29235. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29236. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  29237. const char * STDCALL MDxGetVersion();
  29238. void STDCALL MDxFinalize( MDxSum * );
  29239.  
  29240.  
  29241.  
  29242. #include "mdx.h"
  29243. #include <stdlib.h>
  29244. #include <stdio.h>
  29245. #include <string.h>
  29246.  
  29247. // READLEN % 64 must = 0
  29248. #define READLEN    1048576L // 2^20, 1MB
  29249.  
  29250. void DigestFile( char * );
  29251. void DigestString();
  29252.  
  29253. void main(int argc, char *argv[])
  29254. {
  29255.     printf("%s\n\n", MDxGetVersion());
  29256.  
  29257.     if( argc > 1 )
  29258.         DigestFile( argv[1] );
  29259.     else    
  29260.         DigestString();
  29261.  
  29262. }
  29263.  
  29264. /*
  29265.     I use the 'chunk' method for processing files not because of
  29266.     limitations of my dll, but think what would happen if you
  29267.     tried to load an entire cd image into memory.
  29268. */
  29269. void DigestFile( char *szFName )
  29270. {
  29271.     FILE *file;
  29272.     void *lpData;
  29273.     long flen, mlen;
  29274.     MDxSum mdDataSum;
  29275.     MDxSum md4DataSum;
  29276.  
  29277.     // the 64 is for padding purposes
  29278.     lpData = malloc( READLEN + 64 );
  29279.     
  29280.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  29281.  
  29282.     file = fopen( szFName, "rb" );
  29283.     if( file == NULL )
  29284.     {
  29285.         printf("ERROR: File not found.\n");
  29286.         return;
  29287.     }
  29288.     
  29289.     MDxInit( &mdDataSum );
  29290.     MDxInit( &md4DataSum );
  29291.     
  29292.     fseek( file, 0, SEEK_END );
  29293.     //Get the file length
  29294.     flen = mlen = ftell( file );
  29295.     fseek( file, 0, SEEK_SET );
  29296.     
  29297.     // When it takes a while to process a large file,
  29298.     // remember that for each chunk it has to run 
  29299.     // through the main translation loop 16384 times!
  29300.         
  29301.     printf("Processing %ld byte file: .", flen );
  29302.     
  29303.     while( flen > READLEN )
  29304.     {
  29305.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29306.         {
  29307.             printf("READ ERROR!\n");
  29308.             return;
  29309.         }
  29310.         MD5Translate( lpData, READLEN, &mdDataSum );
  29311.         MD4Translate( lpData, READLEN, &md4DataSum );
  29312.         flen -= READLEN;
  29313.         printf(".");
  29314.     }
  29315.  
  29316.     if (fread( lpData, 1, flen, file ) != flen)
  29317.     {
  29318.         printf("READ ERROR!\n");
  29319.         return;
  29320.     }
  29321.     // This is why I added the new argument to MDxPad
  29322.     // So we can pass the length of the data AND the
  29323.     // Total length of the message
  29324.     // Also it now returns the # of padding bytes added,
  29325.     // this is for files that are an exact multiple of the chunk
  29326.     // length. (Otherwise the padding isn't Translated)
  29327.     flen += MDxPad( lpData, flen, mlen );
  29328.     MD5Translate( lpData, flen, &mdDataSum );    
  29329.     MD4Translate( lpData, flen, &md4DataSum );
  29330.  
  29331.     // New step necessary because of the 'chunking' method
  29332.     MDxFinalize( &mdDataSum );
  29333.     MDxFinalize( &md4DataSum );
  29334.     
  29335.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29336.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29337.     fclose(file);
  29338.         
  29339. }
  29340.  
  29341. void DigestString()
  29342. {
  29343.     
  29344.     //For our demo purposes, no strings bigger than 1024 :)
  29345.     unsigned char lpData[1024] = "";
  29346.     long len = 0;
  29347.     MDxSum mdDataSum;
  29348.  
  29349.     printf("Enter the string to digest: ");
  29350.     scanf("%s", &lpData );
  29351.     len = strlen(lpData);
  29352.     
  29353.     // Have to do this before the Padding...well...it's best anyway;)
  29354.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29355.     
  29356.     // For the strings, we're gonna pad and digest the string
  29357.     // in one pass.
  29358.     MDxInit( &mdDataSum );
  29359.     MDxPad( lpData, len, len );
  29360.     
  29361.     MD5Translate( lpData, len, &mdDataSum );
  29362.         // New step necessary because of the 'chunking' method
  29363.         MDxFinalize( &mdDataSum );
  29364.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29365.     
  29366.     MDxInit( &mdDataSum );
  29367.     MD4Translate( lpData, len, &mdDataSum );    
  29368.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29369.  
  29370.     return;
  29371. }
  29372.  
  29373.  
  29374. -------------- Include
  29375.  
  29376. #ifndef __windows_h__
  29377.         typedef unsigned long DWORD;
  29378.         #define STDCALL _stdcall
  29379. #endif
  29380.  
  29381. typedef struct 
  29382. {
  29383.     DWORD dwSum[4];
  29384. }MDxSum;
  29385.  
  29386. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29387. void STDCALL MDxInit( MDxSum * );
  29388. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29389. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  29390. const char * STDCALL MDxGetVersion();
  29391. void STDCALL MDxFinalize( MDxSum * );
  29392.  
  29393.  
  29394.  
  29395. #include "mdx.h"
  29396. #include <stdlib.h>
  29397. #include <stdio.h>
  29398. #include <string.h>
  29399.  
  29400. // READLEN % 64 must = 0
  29401. #define READLEN    1048576L // 2^20, 1MB
  29402.  
  29403. void DigestFile( char * );
  29404. void DigestString();
  29405.  
  29406. void main(int argc, char *argv[])
  29407. {
  29408.     printf("%s\n\n", MDxGetVersion());
  29409.  
  29410.     if( argc > 1 )
  29411.         DigestFile( argv[1] );
  29412.     else    
  29413.         DigestString();
  29414.  
  29415. }
  29416.  
  29417. /*
  29418.     I use the 'chunk' method for processing files not because of
  29419.     limitations of my dll, but think what would happen if you
  29420.     tried to load an entire cd image into memory.
  29421. */
  29422. void DigestFile( char *szFName )
  29423. {
  29424.     FILE *file;
  29425.     void *lpData;
  29426.     long flen, mlen;
  29427.     MDxSum mdDataSum;
  29428.     MDxSum md4DataSum;
  29429.  
  29430.     // the 64 is for padding purposes
  29431.     lpData = malloc( READLEN + 64 );
  29432.     
  29433.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  29434.  
  29435.     file = fopen( szFName, "rb" );
  29436.     if( file == NULL )
  29437.     {
  29438.         printf("ERROR: File not found.\n");
  29439.         return;
  29440.     }
  29441.     
  29442.     MDxInit( &mdDataSum );
  29443.     MDxInit( &md4DataSum );
  29444.     
  29445.     fseek( file, 0, SEEK_END );
  29446.     //Get the file length
  29447.     flen = mlen = ftell( file );
  29448.     fseek( file, 0, SEEK_SET );
  29449.     
  29450.     // When it takes a while to process a large file,
  29451.     // remember that for each chunk it has to run 
  29452.     // through the main translation loop 16384 times!
  29453.         
  29454.     printf("Processing %ld byte file: .", flen );
  29455.     
  29456.     while( flen > READLEN )
  29457.     {
  29458.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29459.         {
  29460.             printf("READ ERROR!\n");
  29461.             return;
  29462.         }
  29463.         MD5Translate( lpData, READLEN, &mdDataSum );
  29464.         MD4Translate( lpData, READLEN, &md4DataSum );
  29465.         flen -= READLEN;
  29466.         printf(".");
  29467.     }
  29468.  
  29469.     if (fread( lpData, 1, flen, file ) != flen)
  29470.     {
  29471.         printf("READ ERROR!\n");
  29472.         return;
  29473.     }
  29474.     // This is why I added the new argument to MDxPad
  29475.     // So we can pass the length of the data AND the
  29476.     // Total length of the message
  29477.     // Also it now returns the # of padding bytes added,
  29478.     // this is for files that are an exact multiple of the chunk
  29479.     // length. (Otherwise the padding isn't Translated)
  29480.     flen += MDxPad( lpData, flen, mlen );
  29481.     MD5Translate( lpData, flen, &mdDataSum );    
  29482.     MD4Translate( lpData, flen, &md4DataSum );
  29483.  
  29484.     // New step necessary because of the 'chunking' method
  29485.     MDxFinalize( &mdDataSum );
  29486.     MDxFinalize( &md4DataSum );
  29487.     
  29488.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29489.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29490.     fclose(file);
  29491.         
  29492. }
  29493.  
  29494. void DigestString()
  29495. {
  29496.     
  29497.     //For our demo purposes, no strings bigger than 1024 :)
  29498.     unsigned char lpData[1024] = "";
  29499.     long len = 0;
  29500.     MDxSum mdDataSum;
  29501.  
  29502.     printf("Enter the string to digest: ");
  29503.     scanf("%s", &lpData );
  29504.     len = strlen(lpData);
  29505.     
  29506.     // Have to do this before the Padding...well...it's best anyway;)
  29507.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29508.     
  29509.     // For the strings, we're gonna pad and digest the string
  29510.     // in one pass.
  29511.     MDxInit( &mdDataSum );
  29512.     MDxPad( lpData, len, len );
  29513.     
  29514.     MD5Translate( lpData, len, &mdDataSum );
  29515.         // New step necessary because of the 'chunking' method
  29516.         MDxFinalize( &mdDataSum );
  29517.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29518.     
  29519.     MDxInit( &mdDataSum );
  29520.     MD4Translate( lpData, len, &mdDataSum );    
  29521.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29522.  
  29523.     return;
  29524. }
  29525.  
  29526.  
  29527. -------------- Include
  29528.  
  29529. #ifndef __windows_h__
  29530.         typedef unsigned long DWORD;
  29531.         #define STDCALL _stdcall
  29532. #endif
  29533.  
  29534. typedef struct 
  29535. {
  29536.     DWORD dwSum[4];
  29537. }MDxSum;
  29538.  
  29539. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29540. void STDCALL MDxInit( MDxSum * );
  29541. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29542. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  29543. const char * STDCALL MDxGetVersion();
  29544. void STDCALL MDxFinalize( MDxSum * );
  29545.  
  29546.  
  29547. #include "mdx.h"
  29548. #include <stdlib.h>
  29549. #include <stdio.h>
  29550. #include <string.h>
  29551.  
  29552. // READLEN % 64 must = 0
  29553. #define READLEN    1048576L // 2^20, 1MB
  29554.  
  29555. void DigestFile( char * );
  29556. void DigestString();
  29557.  
  29558. void main(int argc, char *argv[])
  29559. {
  29560.     printf("%s\n\n", MDxGetVersion());
  29561.  
  29562.     if( argc > 1 )
  29563.         DigestFile( argv[1] );
  29564.     else    
  29565.         DigestString();
  29566.  
  29567. }
  29568.  
  29569. /*
  29570.     I use the 'chunk' method for processing files not because of
  29571.     limitations of my dll, but think what would happen if you
  29572.     tried to load an entire cd image into memory.
  29573. */
  29574. void DigestFile( char *szFName )
  29575. {
  29576.     FILE *file;
  29577.     void *lpData;
  29578.     long flen, mlen;
  29579.     MDxSum mdDataSum;
  29580.     MDxSum md4DataSum;
  29581.  
  29582.     // the 64 is for padding purposes
  29583.     lpData = malloc( READLEN + 64 );
  29584.     
  29585.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  29586.  
  29587.     file = fopen( szFName, "rb" );
  29588.     if( file == NULL )
  29589.     {
  29590.         printf("ERROR: File not found.\n");
  29591.         return;
  29592.     }
  29593.     
  29594.     MDxInit( &mdDataSum );
  29595.     MDxInit( &md4DataSum );
  29596.     
  29597.     fseek( file, 0, SEEK_END );
  29598.     //Get the file length
  29599.     flen = mlen = ftell( file );
  29600.     fseek( file, 0, SEEK_SET );
  29601.     
  29602.     // When it takes a while to process a large file,
  29603.     // remember that for each chunk it has to run 
  29604.     // through the main translation loop 16384 times!
  29605.         
  29606.     printf("Processing %ld byte file: .", flen );
  29607.     
  29608.     while( flen > READLEN )
  29609.     {
  29610.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29611.         {
  29612.             printf("READ ERROR!\n");
  29613.             return;
  29614.         }
  29615.         MD5Translate( lpData, READLEN, &mdDataSum );
  29616.         MD4Translate( lpData, READLEN, &md4DataSum );
  29617.         flen -= READLEN;
  29618.         printf(".");
  29619.     }
  29620.  
  29621.     if (fread( lpData, 1, flen, file ) != flen)
  29622.     {
  29623.         printf("READ ERROR!\n");
  29624.         return;
  29625.     }
  29626.     // This is why I added the new argument to MDxPad
  29627.     // So we can pass the length of the data AND the
  29628.     // Total length of the message
  29629.     // Also it now returns the # of padding bytes added,
  29630.     // this is for files that are an exact multiple of the chunk
  29631.     // length. (Otherwise the padding isn't Translated)
  29632.     flen += MDxPad( lpData, flen, mlen );
  29633.     MD5Translate( lpData, flen, &mdDataSum );    
  29634.     MD4Translate( lpData, flen, &md4DataSum );
  29635.  
  29636.     // New step necessary because of the 'chunking' method
  29637.     MDxFinalize( &mdDataSum );
  29638.     MDxFinalize( &md4DataSum );
  29639.     
  29640.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29641.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29642.     fclose(file);
  29643.         
  29644. }
  29645.  
  29646. void DigestString()
  29647. {
  29648.     
  29649.     //For our demo purposes, no strings bigger than 1024 :)
  29650.     unsigned char lpData[1024] = "";
  29651.     long len = 0;
  29652.     MDxSum mdDataSum;
  29653.  
  29654.     printf("Enter the string to digest: ");
  29655.     scanf("%s", &lpData );
  29656.     len = strlen(lpData);
  29657.     
  29658.     // Have to do this before the Padding...well...it's best anyway;)
  29659.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29660.     
  29661.     // For the strings, we're gonna pad and digest the string
  29662.     // in one pass.
  29663.     MDxInit( &mdDataSum );
  29664.     MDxPad( lpData, len, len );
  29665.     
  29666.     MD5Translate( lpData, len, &mdDataSum );
  29667.         // New step necessary because of the 'chunking' method
  29668.         MDxFinalize( &mdDataSum );
  29669.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29670.     
  29671.     MDxInit( &mdDataSum );
  29672.     MD4Translate( lpData, len, &mdDataSum );    
  29673.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29674.  
  29675.     return;
  29676. }
  29677.  
  29678.  
  29679. -------------- Include
  29680.  
  29681. #ifndef __windows_h__
  29682.         typedef unsigned long DWORD;
  29683.         #define STDCALL _stdcall
  29684. #endif
  29685.  
  29686. typedef struct 
  29687. {
  29688.     DWORD dwSum[4];
  29689. }MDxSum;
  29690.  
  29691. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29692. void STDCALL MDxInit( MDxSum * );
  29693. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29694. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  29695. const char * STDCALL MDxGetVersion();
  29696. void STDCALL MDxFinalize( MDxSum * );
  29697.  
  29698.  
  29699. #include "mdx.h"
  29700. #include <stdlib.h>
  29701. #include <stdio.h>
  29702. #include <string.h>
  29703.  
  29704. // READLEN % 64 must = 0
  29705. #define READLEN    1048576L // 2^20, 1MB
  29706.  
  29707. void DigestFile( char * );
  29708. void DigestString();
  29709.  
  29710. void main(int argc, char *argv[])
  29711. {
  29712.     printf("%s\n\n", MDxGetVersion());
  29713.  
  29714.     if( argc > 1 )
  29715.         DigestFile( argv[1] );
  29716.     else    
  29717.         DigestString();
  29718.  
  29719. }
  29720.  
  29721. /*
  29722.     I use the 'chunk' method for processing files not because of
  29723.     limitations of my dll, but think what would happen if you
  29724.     tried to load an entire cd image into memory.
  29725. */
  29726. void DigestFile( char *szFName )
  29727. {
  29728.     FILE *file;
  29729.     void *lpData;
  29730.     long flen, mlen;
  29731.     MDxSum mdDataSum;
  29732.     MDxSum md4DataSum;
  29733.  
  29734.     // the 64 is for padding purposes
  29735.     lpData = malloc( READLEN + 64 );
  29736.     
  29737.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  29738.  
  29739.     file = fopen( szFName, "rb" );
  29740.     if( file == NULL )
  29741.     {
  29742.         printf("ERROR: File not found.\n");
  29743.         return;
  29744.     }
  29745.     
  29746.     MDxInit( &mdDataSum );
  29747.     MDxInit( &md4DataSum );
  29748.     
  29749.     fseek( file, 0, SEEK_END );
  29750.     //Get the file length
  29751.     flen = mlen = ftell( file );
  29752.     fseek( file, 0, SEEK_SET );
  29753.     
  29754.     // When it takes a while to process a large file,
  29755.     // remember that for each chunk it has to run 
  29756.     // through the main translation loop 16384 times!
  29757.         
  29758.     printf("Processing %ld byte file: .", flen );
  29759.     
  29760.     while( flen > READLEN )
  29761.     {
  29762.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29763.         {
  29764.             printf("READ ERROR!\n");
  29765.             return;
  29766.         }
  29767.         MD5Translate( lpData, READLEN, &mdDataSum );
  29768.         MD4Translate( lpData, READLEN, &md4DataSum );
  29769.         flen -= READLEN;
  29770.         printf(".");
  29771.     }
  29772.  
  29773.     if (fread( lpData, 1, flen, file ) != flen)
  29774.     {
  29775.         printf("READ ERROR!\n");
  29776.         return;
  29777.     }
  29778.     // This is why I added the new argument to MDxPad
  29779.     // So we can pass the length of the data AND the
  29780.     // Total length of the message
  29781.     // Also it now returns the # of padding bytes added,
  29782.     // this is for files that are an exact multiple of the chunk
  29783.     // length. (Otherwise the padding isn't Translated)
  29784.     flen += MDxPad( lpData, flen, mlen );
  29785.     MD5Translate( lpData, flen, &mdDataSum );    
  29786.     MD4Translate( lpData, flen, &md4DataSum );
  29787.  
  29788.     // New step necessary because of the 'chunking' method
  29789.     MDxFinalize( &mdDataSum );
  29790.     MDxFinalize( &md4DataSum );
  29791.     
  29792.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29793.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29794.     fclose(file);
  29795.         
  29796. }
  29797.  
  29798. void DigestString()
  29799. {
  29800.     
  29801.     //For our demo purposes, no strings bigger than 1024 :)
  29802.     unsigned char lpData[1024] = "";
  29803.     long len = 0;
  29804.     MDxSum mdDataSum;
  29805.  
  29806.     printf("Enter the string to digest: ");
  29807.     scanf("%s", &lpData );
  29808.     len = strlen(lpData);
  29809.     
  29810.     // Have to do this before the Padding...well...it's best anyway;)
  29811.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29812.     
  29813.     // For the strings, we're gonna pad and digest the string
  29814.     // in one pass.
  29815.     MDxInit( &mdDataSum );
  29816.     MDxPad( lpData, len, len );
  29817.     
  29818.     MD5Translate( lpData, len, &mdDataSum );
  29819.         // New step necessary because of the 'chunking' method
  29820.         MDxFinalize( &mdDataSum );
  29821.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29822.     
  29823.     MDxInit( &mdDataSum );
  29824.     MD4Translate( lpData, len, &mdDataSum );    
  29825.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29826.  
  29827.     return;
  29828. }
  29829.  
  29830.  
  29831. -------------- Include
  29832.  
  29833. #ifndef __windows_h__
  29834.         typedef unsigned long DWORD;
  29835.         #define STDCALL _stdcall
  29836. #endif
  29837.  
  29838. typedef struct 
  29839. {
  29840.     DWORD dwSum[4];
  29841. }MDxSum;
  29842.  
  29843. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29844. void STDCALL MDxInit( MDxSum * );
  29845. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29846. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  29847. const char * STDCALL MDxGetVersion();
  29848. void STDCALL MDxFinalize( MDxSum * );
  29849.  
  29850.  
  29851.  
  29852. #include "mdx.h"
  29853. #include <stdlib.h>
  29854. #include <stdio.h>
  29855. #include <string.h>
  29856.  
  29857. // READLEN % 64 must = 0
  29858. #define READLEN    1048576L // 2^20, 1MB
  29859.  
  29860. void DigestFile( char * );
  29861. void DigestString();
  29862.  
  29863. void main(int argc, char *argv[])
  29864. {
  29865.     printf("%s\n\n", MDxGetVersion());
  29866.  
  29867.     if( argc > 1 )
  29868.         DigestFile( argv[1] );
  29869.     else    
  29870.         DigestString();
  29871.  
  29872. }
  29873.  
  29874. /*
  29875.     I use the 'chunk' method for processing files not because of
  29876.     limitations of my dll, but think what would happen if you
  29877.     tried to load an entire cd image into memory.
  29878. */
  29879. void DigestFile( char *szFName )
  29880. {
  29881.     FILE *file;
  29882.     void *lpData;
  29883.     long flen, mlen;
  29884.     MDxSum mdDataSum;
  29885.     MDxSum md4DataSum;
  29886.  
  29887.     // the 64 is for padding purposes
  29888.     lpData = malloc( READLEN + 64 );
  29889.     
  29890.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  29891.  
  29892.     file = fopen( szFName, "rb" );
  29893.     if( file == NULL )
  29894.     {
  29895.         printf("ERROR: File not found.\n");
  29896.         return;
  29897.     }
  29898.     
  29899.     MDxInit( &mdDataSum );
  29900.     MDxInit( &md4DataSum );
  29901.     
  29902.     fseek( file, 0, SEEK_END );
  29903.     //Get the file length
  29904.     flen = mlen = ftell( file );
  29905.     fseek( file, 0, SEEK_SET );
  29906.     
  29907.     // When it takes a while to process a large file,
  29908.     // remember that for each chunk it has to run 
  29909.     // through the main translation loop 16384 times!
  29910.         
  29911.     printf("Processing %ld byte file: .", flen );
  29912.     
  29913.     while( flen > READLEN )
  29914.     {
  29915.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  29916.         {
  29917.             printf("READ ERROR!\n");
  29918.             return;
  29919.         }
  29920.         MD5Translate( lpData, READLEN, &mdDataSum );
  29921.         MD4Translate( lpData, READLEN, &md4DataSum );
  29922.         flen -= READLEN;
  29923.         printf(".");
  29924.     }
  29925.  
  29926.     if (fread( lpData, 1, flen, file ) != flen)
  29927.     {
  29928.         printf("READ ERROR!\n");
  29929.         return;
  29930.     }
  29931.     // This is why I added the new argument to MDxPad
  29932.     // So we can pass the length of the data AND the
  29933.     // Total length of the message
  29934.     // Also it now returns the # of padding bytes added,
  29935.     // this is for files that are an exact multiple of the chunk
  29936.     // length. (Otherwise the padding isn't Translated)
  29937.     flen += MDxPad( lpData, flen, mlen );
  29938.     MD5Translate( lpData, flen, &mdDataSum );    
  29939.     MD4Translate( lpData, flen, &md4DataSum );
  29940.  
  29941.     // New step necessary because of the 'chunking' method
  29942.     MDxFinalize( &mdDataSum );
  29943.     MDxFinalize( &md4DataSum );
  29944.     
  29945.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  29946.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29947.     fclose(file);
  29948.         
  29949. }
  29950.  
  29951. void DigestString()
  29952. {
  29953.     
  29954.     //For our demo purposes, no strings bigger than 1024 :)
  29955.     unsigned char lpData[1024] = "";
  29956.     long len = 0;
  29957.     MDxSum mdDataSum;
  29958.  
  29959.     printf("Enter the string to digest: ");
  29960.     scanf("%s", &lpData );
  29961.     len = strlen(lpData);
  29962.     
  29963.     // Have to do this before the Padding...well...it's best anyway;)
  29964.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  29965.     
  29966.     // For the strings, we're gonna pad and digest the string
  29967.     // in one pass.
  29968.     MDxInit( &mdDataSum );
  29969.     MDxPad( lpData, len, len );
  29970.     
  29971.     MD5Translate( lpData, len, &mdDataSum );
  29972.         // New step necessary because of the 'chunking' method
  29973.         MDxFinalize( &mdDataSum );
  29974.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29975.     
  29976.     MDxInit( &mdDataSum );
  29977.     MD4Translate( lpData, len, &mdDataSum );    
  29978.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  29979.  
  29980.     return;
  29981. }
  29982.  
  29983.  
  29984. -------------- Include
  29985.  
  29986. #ifndef __windows_h__
  29987.         typedef unsigned long DWORD;
  29988.         #define STDCALL _stdcall
  29989. #endif
  29990.  
  29991. typedef struct 
  29992. {
  29993.     DWORD dwSum[4];
  29994. }MDxSum;
  29995.  
  29996. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  29997. void STDCALL MDxInit( MDxSum * );
  29998. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  29999. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30000. const char * STDCALL MDxGetVersion();
  30001. void STDCALL MDxFinalize( MDxSum * );
  30002.  
  30003.  
  30004.  
  30005. #include "mdx.h"
  30006. #include <stdlib.h>
  30007. #include <stdio.h>
  30008. #include <string.h>
  30009.  
  30010. // READLEN % 64 must = 0
  30011. #define READLEN    1048576L // 2^20, 1MB
  30012.  
  30013. void DigestFile( char * );
  30014. void DigestString();
  30015.  
  30016. void main(int argc, char *argv[])
  30017. {
  30018.     printf("%s\n\n", MDxGetVersion());
  30019.  
  30020.     if( argc > 1 )
  30021.         DigestFile( argv[1] );
  30022.     else    
  30023.         DigestString();
  30024.  
  30025. }
  30026.  
  30027. /*
  30028.     I use the 'chunk' method for processing files not because of
  30029.     limitations of my dll, but think what would happen if you
  30030.     tried to load an entire cd image into memory.
  30031. */
  30032. void DigestFile( char *szFName )
  30033. {
  30034.     FILE *file;
  30035.     void *lpData;
  30036.     long flen, mlen;
  30037.     MDxSum mdDataSum;
  30038.     MDxSum md4DataSum;
  30039.  
  30040.     // the 64 is for padding purposes
  30041.     lpData = malloc( READLEN + 64 );
  30042.     
  30043.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30044.  
  30045.     file = fopen( szFName, "rb" );
  30046.     if( file == NULL )
  30047.     {
  30048.         printf("ERROR: File not found.\n");
  30049.         return;
  30050.     }
  30051.     
  30052.     MDxInit( &mdDataSum );
  30053.     MDxInit( &md4DataSum );
  30054.     
  30055.     fseek( file, 0, SEEK_END );
  30056.     //Get the file length
  30057.     flen = mlen = ftell( file );
  30058.     fseek( file, 0, SEEK_SET );
  30059.     
  30060.     // When it takes a while to process a large file,
  30061.     // remember that for each chunk it has to run 
  30062.     // through the main translation loop 16384 times!
  30063.         
  30064.     printf("Processing %ld byte file: .", flen );
  30065.     
  30066.     while( flen > READLEN )
  30067.     {
  30068.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30069.         {
  30070.             printf("READ ERROR!\n");
  30071.             return;
  30072.         }
  30073.         MD5Translate( lpData, READLEN, &mdDataSum );
  30074.         MD4Translate( lpData, READLEN, &md4DataSum );
  30075.         flen -= READLEN;
  30076.         printf(".");
  30077.     }
  30078.  
  30079.     if (fread( lpData, 1, flen, file ) != flen)
  30080.     {
  30081.         printf("READ ERROR!\n");
  30082.         return;
  30083.     }
  30084.     // This is why I added the new argument to MDxPad
  30085.     // So we can pass the length of the data AND the
  30086.     // Total length of the message
  30087.     // Also it now returns the # of padding bytes added,
  30088.     // this is for files that are an exact multiple of the chunk
  30089.     // length. (Otherwise the padding isn't Translated)
  30090.     flen += MDxPad( lpData, flen, mlen );
  30091.     MD5Translate( lpData, flen, &mdDataSum );    
  30092.     MD4Translate( lpData, flen, &md4DataSum );
  30093.  
  30094.     // New step necessary because of the 'chunking' method
  30095.     MDxFinalize( &mdDataSum );
  30096.     MDxFinalize( &md4DataSum );
  30097.     
  30098.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  30099.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30100.     fclose(file);
  30101.         
  30102. }
  30103.  
  30104. void DigestString()
  30105. {
  30106.     
  30107.     //For our demo purposes, no strings bigger than 1024 :)
  30108.     unsigned char lpData[1024] = "";
  30109.     long len = 0;
  30110.     MDxSum mdDataSum;
  30111.  
  30112.     printf("Enter the string to digest: ");
  30113.     scanf("%s", &lpData );
  30114.     len = strlen(lpData);
  30115.     
  30116.     // Have to do this before the Padding...well...it's best anyway;)
  30117.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  30118.     
  30119.     // For the strings, we're gonna pad and digest the string
  30120.     // in one pass.
  30121.     MDxInit( &mdDataSum );
  30122.     MDxPad( lpData, len, len );
  30123.     
  30124.     MD5Translate( lpData, len, &mdDataSum );
  30125.         // New step necessary because of the 'chunking' method
  30126.         MDxFinalize( &mdDataSum );
  30127.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30128.     
  30129.     MDxInit( &mdDataSum );
  30130.     MD4Translate( lpData, len, &mdDataSum );    
  30131.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30132.  
  30133.     return;
  30134. }
  30135.  
  30136.  
  30137. -------------- Include
  30138.  
  30139. #ifndef __windows_h__
  30140.         typedef unsigned long DWORD;
  30141.         #define STDCALL _stdcall
  30142. #endif
  30143.  
  30144. typedef struct 
  30145. {
  30146.     DWORD dwSum[4];
  30147. }MDxSum;
  30148.  
  30149. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  30150. void STDCALL MDxInit( MDxSum * );
  30151. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  30152. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30153. const char * STDCALL MDxGetVersion();
  30154. void STDCALL MDxFinalize( MDxSum * );
  30155.  
  30156.  
  30157.  
  30158. #include "mdx.h"
  30159. #include <stdlib.h>
  30160. #include <stdio.h>
  30161. #include <string.h>
  30162.  
  30163. // READLEN % 64 must = 0
  30164. #define READLEN    1048576L // 2^20, 1MB
  30165.  
  30166. void DigestFile( char * );
  30167. void DigestString();
  30168.  
  30169. void main(int argc, char *argv[])
  30170. {
  30171.     printf("%s\n\n", MDxGetVersion());
  30172.  
  30173.     if( argc > 1 )
  30174.         DigestFile( argv[1] );
  30175.     else    
  30176.         DigestString();
  30177.  
  30178. }
  30179.  
  30180. /*
  30181.     I use the 'chunk' method for processing files not because of
  30182.     limitations of my dll, but think what would happen if you
  30183.     tried to load an entire cd image into memory.
  30184. */
  30185. void DigestFile( char *szFName )
  30186. {
  30187.     FILE *file;
  30188.     void *lpData;
  30189.     long flen, mlen;
  30190.     MDxSum mdDataSum;
  30191.     MDxSum md4DataSum;
  30192.  
  30193.     // the 64 is for padding purposes
  30194.     lpData = malloc( READLEN + 64 );
  30195.     
  30196.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30197.  
  30198.     file = fopen( szFName, "rb" );
  30199.     if( file == NULL )
  30200.     {
  30201.         printf("ERROR: File not found.\n");
  30202.         return;
  30203.     }
  30204.     
  30205.     MDxInit( &mdDataSum );
  30206.     MDxInit( &md4DataSum );
  30207.     
  30208.     fseek( file, 0, SEEK_END );
  30209.     //Get the file length
  30210.     flen = mlen = ftell( file );
  30211.     fseek( file, 0, SEEK_SET );
  30212.     
  30213.     // When it takes a while to process a large file,
  30214.     // remember that for each chunk it has to run 
  30215.     // through the main translation loop 16384 times!
  30216.         
  30217.     printf("Processing %ld byte file: .", flen );
  30218.     
  30219.     while( flen > READLEN )
  30220.     {
  30221.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30222.         {
  30223.             printf("READ ERROR!\n");
  30224.             return;
  30225.         }
  30226.         MD5Translate( lpData, READLEN, &mdDataSum );
  30227.         MD4Translate( lpData, READLEN, &md4DataSum );
  30228.         flen -= READLEN;
  30229.         printf(".");
  30230.     }
  30231.  
  30232.     if (fread( lpData, 1, flen, file ) != flen)
  30233.     {
  30234.         printf("READ ERROR!\n");
  30235.         return;
  30236.     }
  30237.     // This is why I added the new argument to MDxPad
  30238.     // So we can pass the length of the data AND the
  30239.     // Total length of the message
  30240.     // Also it now returns the # of padding bytes added,
  30241.     // this is for files that are an exact multiple of the chunk
  30242.     // length. (Otherwise the padding isn't Translated)
  30243.     flen += MDxPad( lpData, flen, mlen );
  30244.     MD5Translate( lpData, flen, &mdDataSum );    
  30245.     MD4Translate( lpData, flen, &md4DataSum );
  30246.  
  30247.     // New step necessary because of the 'chunking' method
  30248.     MDxFinalize( &mdDataSum );
  30249.     MDxFinalize( &md4DataSum );
  30250.     
  30251.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  30252.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30253.     fclose(file);
  30254.         
  30255. }
  30256.  
  30257. void DigestString()
  30258. {
  30259.     
  30260.     //For our demo purposes, no strings bigger than 1024 :)
  30261.     unsigned char lpData[1024] = "";
  30262.     long len = 0;
  30263.     MDxSum mdDataSum;
  30264.  
  30265.     printf("Enter the string to digest: ");
  30266.     scanf("%s", &lpData );
  30267.     len = strlen(lpData);
  30268.     
  30269.     // Have to do this before the Padding...well...it's best anyway;)
  30270.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  30271.     
  30272.     // For the strings, we're gonna pad and digest the string
  30273.     // in one pass.
  30274.     MDxInit( &mdDataSum );
  30275.     MDxPad( lpData, len, len );
  30276.     
  30277.     MD5Translate( lpData, len, &mdDataSum );
  30278.         // New step necessary because of the 'chunking' method
  30279.         MDxFinalize( &mdDataSum );
  30280.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30281.     
  30282.     MDxInit( &mdDataSum );
  30283.     MD4Translate( lpData, len, &mdDataSum );    
  30284.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30285.  
  30286.     return;
  30287. }
  30288.  
  30289.  
  30290. -------------- Include
  30291.  
  30292. #ifndef __windows_h__
  30293.         typedef unsigned long DWORD;
  30294.         #define STDCALL _stdcall
  30295. #endif
  30296.  
  30297. typedef struct 
  30298. {
  30299.     DWORD dwSum[4];
  30300. }MDxSum;
  30301.  
  30302. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  30303. void STDCALL MDxInit( MDxSum * );
  30304. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  30305. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30306. const char * STDCALL MDxGetVersion();
  30307. void STDCALL MDxFinalize( MDxSum * );
  30308.  
  30309.  
  30310.  
  30311. #include "mdx.h"
  30312. #include <stdlib.h>
  30313. #include <stdio.h>
  30314. #include <string.h>
  30315.  
  30316. // READLEN % 64 must = 0
  30317. #define READLEN    1048576L // 2^20, 1MB
  30318.  
  30319. void DigestFile( char * );
  30320. void DigestString();
  30321.  
  30322. void main(int argc, char *argv[])
  30323. {
  30324.     printf("%s\n\n", MDxGetVersion());
  30325.  
  30326.     if( argc > 1 )
  30327.         DigestFile( argv[1] );
  30328.     else    
  30329.         DigestString();
  30330.  
  30331. }
  30332.  
  30333. /*
  30334.     I use the 'chunk' method for processing files not because of
  30335.     limitations of my dll, but think what would happen if you
  30336.     tried to load an entire cd image into memory.
  30337. */
  30338. void DigestFile( char *szFName )
  30339. {
  30340.     FILE *file;
  30341.     void *lpData;
  30342.     long flen, mlen;
  30343.     MDxSum mdDataSum;
  30344.     MDxSum md4DataSum;
  30345.  
  30346.     // the 64 is for padding purposes
  30347.     lpData = malloc( READLEN + 64 );
  30348.     
  30349.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30350.  
  30351.     file = fopen( szFName, "rb" );
  30352.     if( file == NULL )
  30353.     {
  30354.         printf("ERROR: File not found.\n");
  30355.         return;
  30356.     }
  30357.     
  30358.     MDxInit( &mdDataSum );
  30359.     MDxInit( &md4DataSum );
  30360.     
  30361.     fseek( file, 0, SEEK_END );
  30362.     //Get the file length
  30363.     flen = mlen = ftell( file );
  30364.     fseek( file, 0, SEEK_SET );
  30365.     
  30366.     // When it takes a while to process a large file,
  30367.     // remember that for each chunk it has to run 
  30368.     // through the main translation loop 16384 times!
  30369.         
  30370.     printf("Processing %ld byte file: .", flen );
  30371.     
  30372.     while( flen > READLEN )
  30373.     {
  30374.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30375.         {
  30376.             printf("READ ERROR!\n");
  30377.             return;
  30378.         }
  30379.         MD5Translate( lpData, READLEN, &mdDataSum );
  30380.         MD4Translate( lpData, READLEN, &md4DataSum );
  30381.         flen -= READLEN;
  30382.         printf(".");
  30383.     }
  30384.  
  30385.     if (fread( lpData, 1, flen, file ) != flen)
  30386.     {
  30387.         printf("READ ERROR!\n");
  30388.         return;
  30389.     }
  30390.     // This is why I added the new argument to MDxPad
  30391.     // So we can pass the length of the data AND the
  30392.     // Total length of the message
  30393.     // Also it now returns the # of padding bytes added,
  30394.     // this is for files that are an exact multiple of the chunk
  30395.     // length. (Otherwise the padding isn't Translated)
  30396.     flen += MDxPad( lpData, flen, mlen );
  30397.     MD5Translate( lpData, flen, &mdDataSum );    
  30398.     MD4Translate( lpData, flen, &md4DataSum );
  30399.  
  30400.     // New step necessary because of the 'chunking' method
  30401.     MDxFinalize( &mdDataSum );
  30402.     MDxFinalize( &md4DataSum );
  30403.     
  30404.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  30405.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30406.     fclose(file);
  30407.         
  30408. }
  30409.  
  30410. void DigestString()
  30411. {
  30412.     
  30413.     //For our demo purposes, no strings bigger than 1024 :)
  30414.     unsigned char lpData[1024] = "";
  30415.     long len = 0;
  30416.     MDxSum mdDataSum;
  30417.  
  30418.     printf("Enter the string to digest: ");
  30419.     scanf("%s", &lpData );
  30420.     len = strlen(lpData);
  30421.     
  30422.     // Have to do this before the Padding...well...it's best anyway;)
  30423.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  30424.     
  30425.     // For the strings, we're gonna pad and digest the string
  30426.     // in one pass.
  30427.     MDxInit( &mdDataSum );
  30428.     MDxPad( lpData, len, len );
  30429.     
  30430.     MD5Translate( lpData, len, &mdDataSum );
  30431.         // New step necessary because of the 'chunking' method
  30432.         MDxFinalize( &mdDataSum );
  30433.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30434.     
  30435.     MDxInit( &mdDataSum );
  30436.     MD4Translate( lpData, len, &mdDataSum );    
  30437.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30438.  
  30439.     return;
  30440. }
  30441.  
  30442.  
  30443. -------------- Include
  30444.  
  30445. #ifndef __windows_h__
  30446.         typedef unsigned long DWORD;
  30447.         #define STDCALL _stdcall
  30448. #endif
  30449.  
  30450. typedef struct 
  30451. {
  30452.     DWORD dwSum[4];
  30453. }MDxSum;
  30454.  
  30455. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  30456. void STDCALL MDxInit( MDxSum * );
  30457. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  30458. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30459. const char * STDCALL MDxGetVersion();
  30460. void STDCALL MDxFinalize( MDxSum * );
  30461.  
  30462.  
  30463.  
  30464. #include "mdx.h"
  30465. #include <stdlib.h>
  30466. #include <stdio.h>
  30467. #include <string.h>
  30468.  
  30469. // READLEN % 64 must = 0
  30470. #define READLEN    1048576L // 2^20, 1MB
  30471.  
  30472. void DigestFile( char * );
  30473. void DigestString();
  30474.  
  30475. void main(int argc, char *argv[])
  30476. {
  30477.     printf("%s\n\n", MDxGetVersion());
  30478.  
  30479.     if( argc > 1 )
  30480.         DigestFile( argv[1] );
  30481.     else    
  30482.         DigestString();
  30483.  
  30484. }
  30485.  
  30486. /*
  30487.     I use the 'chunk' method for processing files not because of
  30488.     limitations of my dll, but think what would happen if you
  30489.     tried to load an entire cd image into memory.
  30490. */
  30491. void DigestFile( char *szFName )
  30492. {
  30493.     FILE *file;
  30494.     void *lpData;
  30495.     long flen, mlen;
  30496.     MDxSum mdDataSum;
  30497.     MDxSum md4DataSum;
  30498.  
  30499.     // the 64 is for padding purposes
  30500.     lpData = malloc( READLEN + 64 );
  30501.     
  30502.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30503.  
  30504.     file = fopen( szFName, "rb" );
  30505.     if( file == NULL )
  30506.     {
  30507.         printf("ERROR: File not found.\n");
  30508.         return;
  30509.     }
  30510.     
  30511.     MDxInit( &mdDataSum );
  30512.     MDxInit( &md4DataSum );
  30513.     
  30514.     fseek( file, 0, SEEK_END );
  30515.     //Get the file length
  30516.     flen = mlen = ftell( file );
  30517.     fseek( file, 0, SEEK_SET );
  30518.     
  30519.     // When it takes a while to process a large file,
  30520.     // remember that for each chunk it has to run 
  30521.     // through the main translation loop 16384 times!
  30522.         
  30523.     printf("Processing %ld byte file: .", flen );
  30524.     
  30525.     while( flen > READLEN )
  30526.     {
  30527.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30528.         {
  30529.             printf("READ ERROR!\n");
  30530.             return;
  30531.         }
  30532.         MD5Translate( lpData, READLEN, &mdDataSum );
  30533.         MD4Translate( lpData, READLEN, &md4DataSum );
  30534.         flen -= READLEN;
  30535.         printf(".");
  30536.     }
  30537.  
  30538.     if (fread( lpData, 1, flen, file ) != flen)
  30539.     {
  30540.         printf("READ ERROR!\n");
  30541.         return;
  30542.     }
  30543.     // This is why I added the new argument to MDxPad
  30544.     // So we can pass the length of the data AND the
  30545.     // Total length of the message
  30546.     // Also it now returns the # of padding bytes added,
  30547.     // this is for files that are an exact multiple of the chunk
  30548.     // length. (Otherwise the padding isn't Translated)
  30549.     flen += MDxPad( lpData, flen, mlen );
  30550.     MD5Translate( lpData, flen, &mdDataSum );    
  30551.     MD4Translate( lpData, flen, &md4DataSum );
  30552.  
  30553.     // New step necessary because of the 'chunking' method
  30554.     MDxFinalize( &mdDataSum );
  30555.     MDxFinalize( &md4DataSum );
  30556.     
  30557.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  30558.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30559.     fclose(file);
  30560.         
  30561. }
  30562.  
  30563. void DigestString()
  30564. {
  30565.     
  30566.     //For our demo purposes, no strings bigger than 1024 :)
  30567.     unsigned char lpData[1024] = "";
  30568.     long len = 0;
  30569.     MDxSum mdDataSum;
  30570.  
  30571.     printf("Enter the string to digest: ");
  30572.     scanf("%s", &lpData );
  30573.     len = strlen(lpData);
  30574.     
  30575.     // Have to do this before the Padding...well...it's best anyway;)
  30576.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  30577.     
  30578.     // For the strings, we're gonna pad and digest the string
  30579.     // in one pass.
  30580.     MDxInit( &mdDataSum );
  30581.     MDxPad( lpData, len, len );
  30582.     
  30583.     MD5Translate( lpData, len, &mdDataSum );
  30584.         // New step necessary because of the 'chunking' method
  30585.         MDxFinalize( &mdDataSum );
  30586.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30587.     
  30588.     MDxInit( &mdDataSum );
  30589.     MD4Translate( lpData, len, &mdDataSum );    
  30590.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30591.  
  30592.     return;
  30593. }
  30594.  
  30595.  
  30596. -------------- Include
  30597.  
  30598. #ifndef __windows_h__
  30599.         typedef unsigned long DWORD;
  30600.         #define STDCALL _stdcall
  30601. #endif
  30602.  
  30603. typedef struct 
  30604. {
  30605.     DWORD dwSum[4];
  30606. }MDxSum;
  30607.  
  30608. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  30609. void STDCALL MDxInit( MDxSum * );
  30610. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  30611. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30612. const char * STDCALL MDxGetVersion();
  30613. void STDCALL MDxFinalize( MDxSum * );
  30614.  
  30615.  
  30616.  
  30617. #include "mdx.h"
  30618. #include <stdlib.h>
  30619. #include <stdio.h>
  30620. #include <string.h>
  30621.  
  30622. // READLEN % 64 must = 0
  30623. #define READLEN    1048576L // 2^20, 1MB
  30624.  
  30625. void DigestFile( char * );
  30626. void DigestString();
  30627.  
  30628. void main(int argc, char *argv[])
  30629. {
  30630.     printf("%s\n\n", MDxGetVersion());
  30631.  
  30632.     if( argc > 1 )
  30633.         DigestFile( argv[1] );
  30634.     else    
  30635.         DigestString();
  30636.  
  30637. }
  30638.  
  30639. /*
  30640.     I use the 'chunk' method for processing files not because of
  30641.     limitations of my dll, but think what would happen if you
  30642.     tried to load an entire cd image into memory.
  30643. */
  30644. void DigestFile( char *szFName )
  30645. {
  30646.     FILE *file;
  30647.     void *lpData;
  30648.     long flen, mlen;
  30649.     MDxSum mdDataSum;
  30650.     MDxSum md4DataSum;
  30651.  
  30652.     // the 64 is for padding purposes
  30653.     lpData = malloc( READLEN + 64 );
  30654.     
  30655.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30656.  
  30657.     file = fopen( szFName, "rb" );
  30658.     if( file == NULL )
  30659.     {
  30660.         printf("ERROR: File not found.\n");
  30661.         return;
  30662.     }
  30663.     
  30664.     MDxInit( &mdDataSum );
  30665.     MDxInit( &md4DataSum );
  30666.     
  30667.     fseek( file, 0, SEEK_END );
  30668.     //Get the file length
  30669.     flen = mlen = ftell( file );
  30670.     fseek( file, 0, SEEK_SET );
  30671.     
  30672.     // When it takes a while to process a large file,
  30673.     // remember that for each chunk it has to run 
  30674.     // through the main translation loop 16384 times!
  30675.         
  30676.     printf("Processing %ld byte file: .", flen );
  30677.     
  30678.     while( flen > READLEN )
  30679.     {
  30680.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30681.         {
  30682.             printf("READ ERROR!\n");
  30683.             return;
  30684.         }
  30685.         MD5Translate( lpData, READLEN, &mdDataSum );
  30686.         MD4Translate( lpData, READLEN, &md4DataSum );
  30687.         flen -= READLEN;
  30688.         printf(".");
  30689.     }
  30690.  
  30691.     if (fread( lpData, 1, flen, file ) != flen)
  30692.     {
  30693.         printf("READ ERROR!\n");
  30694.         return;
  30695.     }
  30696.     // This is why I added the new argument to MDxPad
  30697.     // So we can pass the length of the data AND the
  30698.     // Total length of the message
  30699.     // Also it now returns the # of padding bytes added,
  30700.     // this is for files that are an exact multiple of the chunk
  30701.     // length. (Otherwise the padding isn't Translated)
  30702.     flen += MDxPad( lpData, flen, mlen );
  30703.     MD5Translate( lpData, flen, &mdDataSum );    
  30704.     MD4Translate( lpData, flen, &md4DataSum );
  30705.  
  30706.     // New step necessary because of the 'chunking' method
  30707.     MDxFinalize( &mdDataSum );
  30708.     MDxFinalize( &md4DataSum );
  30709.     
  30710.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  30711.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30712.     fclose(file);
  30713.         
  30714. }
  30715.  
  30716. void DigestString()
  30717. {
  30718.     
  30719.     //For our demo purposes, no strings bigger than 1024 :)
  30720.     unsigned char lpData[1024] = "";
  30721.     long len = 0;
  30722.     MDxSum mdDataSum;
  30723.  
  30724.     printf("Enter the string to digest: ");
  30725.     scanf("%s", &lpData );
  30726.     len = strlen(lpData);
  30727.     
  30728.     // Have to do this before the Padding...well...it's best anyway;)
  30729.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  30730.     
  30731.     // For the strings, we're gonna pad and digest the string
  30732.     // in one pass.
  30733.     MDxInit( &mdDataSum );
  30734.     MDxPad( lpData, len, len );
  30735.     
  30736.     MD5Translate( lpData, len, &mdDataSum );
  30737.         // New step necessary because of the 'chunking' method
  30738.         MDxFinalize( &mdDataSum );
  30739.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30740.     
  30741.     MDxInit( &mdDataSum );
  30742.     MD4Translate( lpData, len, &mdDataSum );    
  30743.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30744.  
  30745.     return;
  30746. }
  30747.  
  30748.  
  30749. -------------- Include
  30750.  
  30751. #ifndef __windows_h__
  30752.         typedef unsigned long DWORD;
  30753.         #define STDCALL _stdcall
  30754. #endif
  30755.  
  30756. typedef struct 
  30757. {
  30758.     DWORD dwSum[4];
  30759. }MDxSum;
  30760.  
  30761. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  30762. void STDCALL MDxInit( MDxSum * );
  30763. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  30764. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30765. const char * STDCALL MDxGetVersion();
  30766. void STDCALL MDxFinalize( MDxSum * );
  30767.  
  30768.  
  30769.  
  30770. #include "mdx.h"
  30771. #include <stdlib.h>
  30772. #include <stdio.h>
  30773. #include <string.h>
  30774.  
  30775. // READLEN % 64 must = 0
  30776. #define READLEN    1048576L // 2^20, 1MB
  30777.  
  30778. void DigestFile( char * );
  30779. void DigestString();
  30780.  
  30781. void main(int argc, char *argv[])
  30782. {
  30783.     printf("%s\n\n", MDxGetVersion());
  30784.  
  30785.     if( argc > 1 )
  30786.         DigestFile( argv[1] );
  30787.     else    
  30788.         DigestString();
  30789.  
  30790. }
  30791.  
  30792. /*
  30793.     I use the 'chunk' method for processing files not because of
  30794.     limitations of my dll, but think what would happen if you
  30795.     tried to load an entire cd image into memory.
  30796. */
  30797. void DigestFile( char *szFName )
  30798. {
  30799.     FILE *file;
  30800.     void *lpData;
  30801.     long flen, mlen;
  30802.     MDxSum mdDataSum;
  30803.     MDxSum md4DataSum;
  30804.  
  30805.     // the 64 is for padding purposes
  30806.     lpData = malloc( READLEN + 64 );
  30807.     
  30808.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30809.  
  30810.     file = fopen( szFName, "rb" );
  30811.     if( file == NULL )
  30812.     {
  30813.         printf("ERROR: File not found.\n");
  30814.         return;
  30815.     }
  30816.     
  30817.     MDxInit( &mdDataSum );
  30818.     MDxInit( &md4DataSum );
  30819.     
  30820.     fseek( file, 0, SEEK_END );
  30821.     //Get the file length
  30822.     flen = mlen = ftell( file );
  30823.     fseek( file, 0, SEEK_SET );
  30824.     
  30825.     // When it takes a while to process a large file,
  30826.     // remember that for each chunk it has to run 
  30827.     // through the main translation loop 16384 times!
  30828.         
  30829.     printf("Processing %ld byte file: .", flen );
  30830.     
  30831.     while( flen > READLEN )
  30832.     {
  30833.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30834.         {
  30835.             printf("READ ERROR!\n");
  30836.             return;
  30837.         }
  30838.         MD5Translate( lpData, READLEN, &mdDataSum );
  30839.         MD4Translate( lpData, READLEN, &md4DataSum );
  30840.         flen -= READLEN;
  30841.         printf(".");
  30842.     }
  30843.  
  30844.     if (fread( lpData, 1, flen, file ) != flen)
  30845.     {
  30846.         printf("READ ERROR!\n");
  30847.         return;
  30848.     }
  30849.     // This is why I added the new argument to MDxPad
  30850.     // So we can pass the length of the data AND the
  30851.     // Total length of the message
  30852.     // Also it now returns the # of padding bytes added,
  30853.     // this is for files that are an exact multiple of the chunk
  30854.     // length. (Otherwise the padding isn't Translated)
  30855.     flen += MDxPad( lpData, flen, mlen );
  30856.     MD5Translate( lpData, flen, &mdDataSum );    
  30857.     MD4Translate( lpData, flen, &md4DataSum );
  30858.  
  30859.     // New step necessary because of the 'chunking' method
  30860.     MDxFinalize( &mdDataSum );
  30861.     MDxFinalize( &md4DataSum );
  30862.     
  30863.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  30864.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30865.     fclose(file);
  30866.         
  30867. }
  30868.  
  30869. void DigestString()
  30870. {
  30871.     
  30872.     //For our demo purposes, no strings bigger than 1024 :)
  30873.     unsigned char lpData[1024] = "";
  30874.     long len = 0;
  30875.     MDxSum mdDataSum;
  30876.  
  30877.     printf("Enter the string to digest: ");
  30878.     scanf("%s", &lpData );
  30879.     len = strlen(lpData);
  30880.     
  30881.     // Have to do this before the Padding...well...it's best anyway;)
  30882.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  30883.     
  30884.     // For the strings, we're gonna pad and digest the string
  30885.     // in one pass.
  30886.     MDxInit( &mdDataSum );
  30887.     MDxPad( lpData, len, len );
  30888.     
  30889.     MD5Translate( lpData, len, &mdDataSum );
  30890.         // New step necessary because of the 'chunking' method
  30891.         MDxFinalize( &mdDataSum );
  30892.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30893.     
  30894.     MDxInit( &mdDataSum );
  30895.     MD4Translate( lpData, len, &mdDataSum );    
  30896.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  30897.  
  30898.     return;
  30899. }
  30900.  
  30901.  
  30902. -------------- Include
  30903.  
  30904. #ifndef __windows_h__
  30905.         typedef unsigned long DWORD;
  30906.         #define STDCALL _stdcall
  30907. #endif
  30908.  
  30909. typedef struct 
  30910. {
  30911.     DWORD dwSum[4];
  30912. }MDxSum;
  30913.  
  30914. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  30915. void STDCALL MDxInit( MDxSum * );
  30916. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  30917. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  30918. const char * STDCALL MDxGetVersion();
  30919. void STDCALL MDxFinalize( MDxSum * );
  30920.  
  30921.  
  30922. #include "mdx.h"
  30923. #include <stdlib.h>
  30924. #include <stdio.h>
  30925. #include <string.h>
  30926.  
  30927. // READLEN % 64 must = 0
  30928. #define READLEN    1048576L // 2^20, 1MB
  30929.  
  30930. void DigestFile( char * );
  30931. void DigestString();
  30932.  
  30933. void main(int argc, char *argv[])
  30934. {
  30935.     printf("%s\n\n", MDxGetVersion());
  30936.  
  30937.     if( argc > 1 )
  30938.         DigestFile( argv[1] );
  30939.     else    
  30940.         DigestString();
  30941.  
  30942. }
  30943.  
  30944. /*
  30945.     I use the 'chunk' method for processing files not because of
  30946.     limitations of my dll, but think what would happen if you
  30947.     tried to load an entire cd image into memory.
  30948. */
  30949. void DigestFile( char *szFName )
  30950. {
  30951.     FILE *file;
  30952.     void *lpData;
  30953.     long flen, mlen;
  30954.     MDxSum mdDataSum;
  30955.     MDxSum md4DataSum;
  30956.  
  30957.     // the 64 is for padding purposes
  30958.     lpData = malloc( READLEN + 64 );
  30959.     
  30960.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  30961.  
  30962.     file = fopen( szFName, "rb" );
  30963.     if( file == NULL )
  30964.     {
  30965.         printf("ERROR: File not found.\n");
  30966.         return;
  30967.     }
  30968.     
  30969.     MDxInit( &mdDataSum );
  30970.     MDxInit( &md4DataSum );
  30971.     
  30972.     fseek( file, 0, SEEK_END );
  30973.     //Get the file length
  30974.     flen = mlen = ftell( file );
  30975.     fseek( file, 0, SEEK_SET );
  30976.     
  30977.     // When it takes a while to process a large file,
  30978.     // remember that for each chunk it has to run 
  30979.     // through the main translation loop 16384 times!
  30980.         
  30981.     printf("Processing %ld byte file: .", flen );
  30982.     
  30983.     while( flen > READLEN )
  30984.     {
  30985.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  30986.         {
  30987.             printf("READ ERROR!\n");
  30988.             return;
  30989.         }
  30990.         MD5Translate( lpData, READLEN, &mdDataSum );
  30991.         MD4Translate( lpData, READLEN, &md4DataSum );
  30992.         flen -= READLEN;
  30993.         printf(".");
  30994.     }
  30995.  
  30996.     if (fread( lpData, 1, flen, file ) != flen)
  30997.     {
  30998.         printf("READ ERROR!\n");
  30999.         return;
  31000.     }
  31001.     // This is why I added the new argument to MDxPad
  31002.     // So we can pass the length of the data AND the
  31003.     // Total length of the message
  31004.     // Also it now returns the # of padding bytes added,
  31005.     // this is for files that are an exact multiple of the chunk
  31006.     // length. (Otherwise the padding isn't Translated)
  31007.     flen += MDxPad( lpData, flen, mlen );
  31008.     MD5Translate( lpData, flen, &mdDataSum );    
  31009.     MD4Translate( lpData, flen, &md4DataSum );
  31010.  
  31011.     // New step necessary because of the 'chunking' method
  31012.     MDxFinalize( &mdDataSum );
  31013.     MDxFinalize( &md4DataSum );
  31014.     
  31015.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31016.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31017.     fclose(file);
  31018.         
  31019. }
  31020.  
  31021. void DigestString()
  31022. {
  31023.     
  31024.     //For our demo purposes, no strings bigger than 1024 :)
  31025.     unsigned char lpData[1024] = "";
  31026.     long len = 0;
  31027.     MDxSum mdDataSum;
  31028.  
  31029.     printf("Enter the string to digest: ");
  31030.     scanf("%s", &lpData );
  31031.     len = strlen(lpData);
  31032.     
  31033.     // Have to do this before the Padding...well...it's best anyway;)
  31034.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31035.     
  31036.     // For the strings, we're gonna pad and digest the string
  31037.     // in one pass.
  31038.     MDxInit( &mdDataSum );
  31039.     MDxPad( lpData, len, len );
  31040.     
  31041.     MD5Translate( lpData, len, &mdDataSum );
  31042.         // New step necessary because of the 'chunking' method
  31043.         MDxFinalize( &mdDataSum );
  31044.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31045.     
  31046.     MDxInit( &mdDataSum );
  31047.     MD4Translate( lpData, len, &mdDataSum );    
  31048.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31049.  
  31050.     return;
  31051. }
  31052.  
  31053.  
  31054. -------------- Include
  31055.  
  31056. #ifndef __windows_h__
  31057.         typedef unsigned long DWORD;
  31058.         #define STDCALL _stdcall
  31059. #endif
  31060.  
  31061. typedef struct 
  31062. {
  31063.     DWORD dwSum[4];
  31064. }MDxSum;
  31065.  
  31066. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31067. void STDCALL MDxInit( MDxSum * );
  31068. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31069. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31070. const char * STDCALL MDxGetVersion();
  31071. void STDCALL MDxFinalize( MDxSum * );
  31072.  
  31073.  
  31074. #include "mdx.h"
  31075. #include <stdlib.h>
  31076. #include <stdio.h>
  31077. #include <string.h>
  31078.  
  31079. // READLEN % 64 must = 0
  31080. #define READLEN    1048576L // 2^20, 1MB
  31081.  
  31082. void DigestFile( char * );
  31083. void DigestString();
  31084.  
  31085. void main(int argc, char *argv[])
  31086. {
  31087.     printf("%s\n\n", MDxGetVersion());
  31088.  
  31089.     if( argc > 1 )
  31090.         DigestFile( argv[1] );
  31091.     else    
  31092.         DigestString();
  31093.  
  31094. }
  31095.  
  31096. /*
  31097.     I use the 'chunk' method for processing files not because of
  31098.     limitations of my dll, but think what would happen if you
  31099.     tried to load an entire cd image into memory.
  31100. */
  31101. void DigestFile( char *szFName )
  31102. {
  31103.     FILE *file;
  31104.     void *lpData;
  31105.     long flen, mlen;
  31106.     MDxSum mdDataSum;
  31107.     MDxSum md4DataSum;
  31108.  
  31109.     // the 64 is for padding purposes
  31110.     lpData = malloc( READLEN + 64 );
  31111.     
  31112.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  31113.  
  31114.     file = fopen( szFName, "rb" );
  31115.     if( file == NULL )
  31116.     {
  31117.         printf("ERROR: File not found.\n");
  31118.         return;
  31119.     }
  31120.     
  31121.     MDxInit( &mdDataSum );
  31122.     MDxInit( &md4DataSum );
  31123.     
  31124.     fseek( file, 0, SEEK_END );
  31125.     //Get the file length
  31126.     flen = mlen = ftell( file );
  31127.     fseek( file, 0, SEEK_SET );
  31128.     
  31129.     // When it takes a while to process a large file,
  31130.     // remember that for each chunk it has to run 
  31131.     // through the main translation loop 16384 times!
  31132.         
  31133.     printf("Processing %ld byte file: .", flen );
  31134.     
  31135.     while( flen > READLEN )
  31136.     {
  31137.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  31138.         {
  31139.             printf("READ ERROR!\n");
  31140.             return;
  31141.         }
  31142.         MD5Translate( lpData, READLEN, &mdDataSum );
  31143.         MD4Translate( lpData, READLEN, &md4DataSum );
  31144.         flen -= READLEN;
  31145.         printf(".");
  31146.     }
  31147.  
  31148.     if (fread( lpData, 1, flen, file ) != flen)
  31149.     {
  31150.         printf("READ ERROR!\n");
  31151.         return;
  31152.     }
  31153.     // This is why I added the new argument to MDxPad
  31154.     // So we can pass the length of the data AND the
  31155.     // Total length of the message
  31156.     // Also it now returns the # of padding bytes added,
  31157.     // this is for files that are an exact multiple of the chunk
  31158.     // length. (Otherwise the padding isn't Translated)
  31159.     flen += MDxPad( lpData, flen, mlen );
  31160.     MD5Translate( lpData, flen, &mdDataSum );    
  31161.     MD4Translate( lpData, flen, &md4DataSum );
  31162.  
  31163.     // New step necessary because of the 'chunking' method
  31164.     MDxFinalize( &mdDataSum );
  31165.     MDxFinalize( &md4DataSum );
  31166.     
  31167.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31168.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31169.     fclose(file);
  31170.         
  31171. }
  31172.  
  31173. void DigestString()
  31174. {
  31175.     
  31176.     //For our demo purposes, no strings bigger than 1024 :)
  31177.     unsigned char lpData[1024] = "";
  31178.     long len = 0;
  31179.     MDxSum mdDataSum;
  31180.  
  31181.     printf("Enter the string to digest: ");
  31182.     scanf("%s", &lpData );
  31183.     len = strlen(lpData);
  31184.     
  31185.     // Have to do this before the Padding...well...it's best anyway;)
  31186.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31187.     
  31188.     // For the strings, we're gonna pad and digest the string
  31189.     // in one pass.
  31190.     MDxInit( &mdDataSum );
  31191.     MDxPad( lpData, len, len );
  31192.     
  31193.     MD5Translate( lpData, len, &mdDataSum );
  31194.         // New step necessary because of the 'chunking' method
  31195.         MDxFinalize( &mdDataSum );
  31196.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31197.     
  31198.     MDxInit( &mdDataSum );
  31199.     MD4Translate( lpData, len, &mdDataSum );    
  31200.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31201.  
  31202.     return;
  31203. }
  31204.  
  31205.  
  31206. -------------- Include
  31207.  
  31208. #ifndef __windows_h__
  31209.         typedef unsigned long DWORD;
  31210.         #define STDCALL _stdcall
  31211. #endif
  31212.  
  31213. typedef struct 
  31214. {
  31215.     DWORD dwSum[4];
  31216. }MDxSum;
  31217.  
  31218. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31219. void STDCALL MDxInit( MDxSum * );
  31220. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31221. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31222. const char * STDCALL MDxGetVersion();
  31223. void STDCALL MDxFinalize( MDxSum * );
  31224.  
  31225. #include "mdx.h"
  31226. #include <stdlib.h>
  31227. #include <stdio.h>
  31228. #include <string.h>
  31229.  
  31230. // READLEN % 64 must = 0
  31231. #define READLEN    1048576L // 2^20, 1MB
  31232.  
  31233. void DigestFile( char * );
  31234. void DigestString();
  31235.  
  31236. void main(int argc, char *argv[])
  31237. {
  31238.     printf("%s\n\n", MDxGetVersion());
  31239.  
  31240.     if( argc > 1 )
  31241.         DigestFile( argv[1] );
  31242.     else    
  31243.         DigestString();
  31244.  
  31245. }
  31246.  
  31247. /*
  31248.     I use the 'chunk' method for processing files not because of
  31249.     limitations of my dll, but think what would happen if you
  31250.     tried to load an entire cd image into memory.
  31251. */
  31252. void DigestFile( char *szFName )
  31253. {
  31254.     FILE *file;
  31255.     void *lpData;
  31256.     long flen, mlen;
  31257.     MDxSum mdDataSum;
  31258.     MDxSum md4DataSum;
  31259.  
  31260.     // the 64 is for padding purposes
  31261.     lpData = malloc( READLEN + 64 );
  31262.     
  31263.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  31264.  
  31265.     file = fopen( szFName, "rb" );
  31266.     if( file == NULL )
  31267.     {
  31268.         printf("ERROR: File not found.\n");
  31269.         return;
  31270.     }
  31271.     
  31272.     MDxInit( &mdDataSum );
  31273.     MDxInit( &md4DataSum );
  31274.     
  31275.     fseek( file, 0, SEEK_END );
  31276.     //Get the file length
  31277.     flen = mlen = ftell( file );
  31278.     fseek( file, 0, SEEK_SET );
  31279.     
  31280.     // When it takes a while to process a large file,
  31281.     // remember that for each chunk it has to run 
  31282.     // through the main translation loop 16384 times!
  31283.         
  31284.     printf("Processing %ld byte file: .", flen );
  31285.     
  31286.     while( flen > READLEN )
  31287.     {
  31288.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  31289.         {
  31290.             printf("READ ERROR!\n");
  31291.             return;
  31292.         }
  31293.         MD5Translate( lpData, READLEN, &mdDataSum );
  31294.         MD4Translate( lpData, READLEN, &md4DataSum );
  31295.         flen -= READLEN;
  31296.         printf(".");
  31297.     }
  31298.  
  31299.     if (fread( lpData, 1, flen, file ) != flen)
  31300.     {
  31301.         printf("READ ERROR!\n");
  31302.         return;
  31303.     }
  31304.     // This is why I added the new argument to MDxPad
  31305.     // So we can pass the length of the data AND the
  31306.     // Total length of the message
  31307.     // Also it now returns the # of padding bytes added,
  31308.     // this is for files that are an exact multiple of the chunk
  31309.     // length. (Otherwise the padding isn't Translated)
  31310.     flen += MDxPad( lpData, flen, mlen );
  31311.     MD5Translate( lpData, flen, &mdDataSum );    
  31312.     MD4Translate( lpData, flen, &md4DataSum );
  31313.  
  31314.     // New step necessary because of the 'chunking' method
  31315.     MDxFinalize( &mdDataSum );
  31316.     MDxFinalize( &md4DataSum );
  31317.     
  31318.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31319.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31320.     fclose(file);
  31321.         
  31322. }
  31323.  
  31324. void DigestString()
  31325. {
  31326.     
  31327.     //For our demo purposes, no strings bigger than 1024 :)
  31328.     unsigned char lpData[1024] = "";
  31329.     long len = 0;
  31330.     MDxSum mdDataSum;
  31331.  
  31332.     printf("Enter the string to digest: ");
  31333.     scanf("%s", &lpData );
  31334.     len = strlen(lpData);
  31335.     
  31336.     // Have to do this before the Padding...well...it's best anyway;)
  31337.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31338.     
  31339.     // For the strings, we're gonna pad and digest the string
  31340.     // in one pass.
  31341.     MDxInit( &mdDataSum );
  31342.     MDxPad( lpData, len, len );
  31343.     
  31344.     MD5Translate( lpData, len, &mdDataSum );
  31345.         // New step necessary because of the 'chunking' method
  31346.         MDxFinalize( &mdDataSum );
  31347.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31348.     
  31349.     MDxInit( &mdDataSum );
  31350.     MD4Translate( lpData, len, &mdDataSum );    
  31351.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31352.  
  31353.     return;
  31354. }
  31355.  
  31356.  
  31357. -------------- Include
  31358.  
  31359. #ifndef __windows_h__
  31360.         typedef unsigned long DWORD;
  31361.         #define STDCALL _stdcall
  31362. #endif
  31363.  
  31364. typedef struct 
  31365. {
  31366.     DWORD dwSum[4];
  31367. }MDxSum;
  31368.  
  31369. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31370. void STDCALL MDxInit( MDxSum * );
  31371. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31372. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31373. const char * STDCALL MDxGetVersion();
  31374. void STDCALL MDxFinalize( MDxSum * );
  31375.  
  31376.  
  31377.  
  31378. #include "mdx.h"
  31379. #include <stdlib.h>
  31380. #include <stdio.h>
  31381. #include <string.h>
  31382.  
  31383. // READLEN % 64 must = 0
  31384. #define READLEN    1048576L // 2^20, 1MB
  31385.  
  31386. void DigestFile( char * );
  31387. void DigestString();
  31388.  
  31389. void main(int argc, char *argv[])
  31390. {
  31391.     printf("%s\n\n", MDxGetVersion());
  31392.  
  31393.     if( argc > 1 )
  31394.         DigestFile( argv[1] );
  31395.     else    
  31396.         DigestString();
  31397.  
  31398. }
  31399.  
  31400. /*
  31401.     I use the 'chunk' method for processing files not because of
  31402.     limitations of my dll, but think what would happen if you
  31403.     tried to load an entire cd image into memory.
  31404. */
  31405. void DigestFile( char *szFName )
  31406. {
  31407.     FILE *file;
  31408.     void *lpData;
  31409.     long flen, mlen;
  31410.     MDxSum mdDataSum;
  31411.     MDxSum md4DataSum;
  31412.  
  31413.     // the 64 is for padding purposes
  31414.     lpData = malloc( READLEN + 64 );
  31415.     
  31416.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  31417.  
  31418.     file = fopen( szFName, "rb" );
  31419.     if( file == NULL )
  31420.     {
  31421.         printf("ERROR: File not found.\n");
  31422.         return;
  31423.     }
  31424.     
  31425.     MDxInit( &mdDataSum );
  31426.     MDxInit( &md4DataSum );
  31427.     
  31428.     fseek( file, 0, SEEK_END );
  31429.     //Get the file length
  31430.     flen = mlen = ftell( file );
  31431.     fseek( file, 0, SEEK_SET );
  31432.     
  31433.     // When it takes a while to process a large file,
  31434.     // remember that for each chunk it has to run 
  31435.     // through the main translation loop 16384 times!
  31436.         
  31437.     printf("Processing %ld byte file: .", flen );
  31438.     
  31439.     while( flen > READLEN )
  31440.     {
  31441.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  31442.         {
  31443.             printf("READ ERROR!\n");
  31444.             return;
  31445.         }
  31446.         MD5Translate( lpData, READLEN, &mdDataSum );
  31447.         MD4Translate( lpData, READLEN, &md4DataSum );
  31448.         flen -= READLEN;
  31449.         printf(".");
  31450.     }
  31451.  
  31452.     if (fread( lpData, 1, flen, file ) != flen)
  31453.     {
  31454.         printf("READ ERROR!\n");
  31455.         return;
  31456.     }
  31457.     // This is why I added the new argument to MDxPad
  31458.     // So we can pass the length of the data AND the
  31459.     // Total length of the message
  31460.     // Also it now returns the # of padding bytes added,
  31461.     // this is for files that are an exact multiple of the chunk
  31462.     // length. (Otherwise the padding isn't Translated)
  31463.     flen += MDxPad( lpData, flen, mlen );
  31464.     MD5Translate( lpData, flen, &mdDataSum );    
  31465.     MD4Translate( lpData, flen, &md4DataSum );
  31466.  
  31467.     // New step necessary because of the 'chunking' method
  31468.     MDxFinalize( &mdDataSum );
  31469.     MDxFinalize( &md4DataSum );
  31470.     
  31471.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31472.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31473.     fclose(file);
  31474.         
  31475. }
  31476.  
  31477. void DigestString()
  31478. {
  31479.     
  31480.     //For our demo purposes, no strings bigger than 1024 :)
  31481.     unsigned char lpData[1024] = "";
  31482.     long len = 0;
  31483.     MDxSum mdDataSum;
  31484.  
  31485.     printf("Enter the string to digest: ");
  31486.     scanf("%s", &lpData );
  31487.     len = strlen(lpData);
  31488.     
  31489.     // Have to do this before the Padding...well...it's best anyway;)
  31490.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31491.     
  31492.     // For the strings, we're gonna pad and digest the string
  31493.     // in one pass.
  31494.     MDxInit( &mdDataSum );
  31495.     MDxPad( lpData, len, len );
  31496.     
  31497.     MD5Translate( lpData, len, &mdDataSum );
  31498.         // New step necessary because of the 'chunking' method
  31499.         MDxFinalize( &mdDataSum );
  31500.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31501.     
  31502.     MDxInit( &mdDataSum );
  31503.     MD4Translate( lpData, len, &mdDataSum );    
  31504.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31505.  
  31506.     return;
  31507. }
  31508.  
  31509.  
  31510. -------------- Include
  31511.  
  31512. #ifndef __windows_h__
  31513.         typedef unsigned long DWORD;
  31514.         #define STDCALL _stdcall
  31515. #endif
  31516.  
  31517. typedef struct 
  31518. {
  31519.     DWORD dwSum[4];
  31520. }MDxSum;
  31521.  
  31522. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31523. void STDCALL MDxInit( MDxSum * );
  31524. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31525. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31526. const char * STDCALL MDxGetVersion();
  31527. void STDCALL MDxFinalize( MDxSum * );
  31528.  
  31529.  
  31530.  
  31531. #include "mdx.h"
  31532. #include <stdlib.h>
  31533. #include <stdio.h>
  31534. #include <string.h>
  31535.  
  31536. // READLEN % 64 must = 0
  31537. #define READLEN    1048576L // 2^20, 1MB
  31538.  
  31539. void DigestFile( char * );
  31540. void DigestString();
  31541.  
  31542. void main(int argc, char *argv[])
  31543. {
  31544.     printf("%s\n\n", MDxGetVersion());
  31545.  
  31546.     if( argc > 1 )
  31547.         DigestFile( argv[1] );
  31548.     else    
  31549.         DigestString();
  31550.  
  31551. }
  31552.  
  31553. /*
  31554.     I use the 'chunk' method for processing files not because of
  31555.     limitations of my dll, but think what would happen if you
  31556.     tried to load an entire cd image into memory.
  31557. */
  31558. void DigestFile( char *szFName )
  31559. {
  31560.     FILE *file;
  31561.     void *lpData;
  31562.     long flen, mlen;
  31563.     MDxSum mdDataSum;
  31564.     MDxSum md4DataSum;
  31565.  
  31566.     // the 64 is for padding purposes
  31567.     lpData = malloc( READLEN + 64 );
  31568.     
  31569.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  31570.  
  31571.     file = fopen( szFName, "rb" );
  31572.     if( file == NULL )
  31573.     {
  31574.         printf("ERROR: File not found.\n");
  31575.         return;
  31576.     }
  31577.     
  31578.     MDxInit( &mdDataSum );
  31579.     MDxInit( &md4DataSum );
  31580.     
  31581.     fseek( file, 0, SEEK_END );
  31582.     //Get the file length
  31583.     flen = mlen = ftell( file );
  31584.     fseek( file, 0, SEEK_SET );
  31585.     
  31586.     // When it takes a while to process a large file,
  31587.     // remember that for each chunk it has to run 
  31588.     // through the main translation loop 16384 times!
  31589.         
  31590.     printf("Processing %ld byte file: .", flen );
  31591.     
  31592.     while( flen > READLEN )
  31593.     {
  31594.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  31595.         {
  31596.             printf("READ ERROR!\n");
  31597.             return;
  31598.         }
  31599.         MD5Translate( lpData, READLEN, &mdDataSum );
  31600.         MD4Translate( lpData, READLEN, &md4DataSum );
  31601.         flen -= READLEN;
  31602.         printf(".");
  31603.     }
  31604.  
  31605.     if (fread( lpData, 1, flen, file ) != flen)
  31606.     {
  31607.         printf("READ ERROR!\n");
  31608.         return;
  31609.     }
  31610.     // This is why I added the new argument to MDxPad
  31611.     // So we can pass the length of the data AND the
  31612.     // Total length of the message
  31613.     // Also it now returns the # of padding bytes added,
  31614.     // this is for files that are an exact multiple of the chunk
  31615.     // length. (Otherwise the padding isn't Translated)
  31616.     flen += MDxPad( lpData, flen, mlen );
  31617.     MD5Translate( lpData, flen, &mdDataSum );    
  31618.     MD4Translate( lpData, flen, &md4DataSum );
  31619.  
  31620.     // New step necessary because of the 'chunking' method
  31621.     MDxFinalize( &mdDataSum );
  31622.     MDxFinalize( &md4DataSum );
  31623.     
  31624.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31625.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31626.     fclose(file);
  31627.         
  31628. }
  31629.  
  31630. void DigestString()
  31631. {
  31632.     
  31633.     //For our demo purposes, no strings bigger than 1024 :)
  31634.     unsigned char lpData[1024] = "";
  31635.     long len = 0;
  31636.     MDxSum mdDataSum;
  31637.  
  31638.     printf("Enter the string to digest: ");
  31639.     scanf("%s", &lpData );
  31640.     len = strlen(lpData);
  31641.     
  31642.     // Have to do this before the Padding...well...it's best anyway;)
  31643.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31644.     
  31645.     // For the strings, we're gonna pad and digest the string
  31646.     // in one pass.
  31647.     MDxInit( &mdDataSum );
  31648.     MDxPad( lpData, len, len );
  31649.     
  31650.     MD5Translate( lpData, len, &mdDataSum );
  31651.         // New step necessary because of the 'chunking' method
  31652.         MDxFinalize( &mdDataSum );
  31653.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31654.     
  31655.     MDxInit( &mdDataSum );
  31656.     MD4Translate( lpData, len, &mdDataSum );    
  31657.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31658.  
  31659.     return;
  31660. }
  31661.  
  31662.  
  31663. -------------- Include
  31664.  
  31665. #ifndef __windows_h__
  31666.         typedef unsigned long DWORD;
  31667.         #define STDCALL _stdcall
  31668. #endif
  31669.  
  31670. typedef struct 
  31671. {
  31672.     DWORD dwSum[4];
  31673. }MDxSum;
  31674.  
  31675. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31676. void STDCALL MDxInit( MDxSum * );
  31677. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31678. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31679. const char * STDCALL MDxGetVersion();
  31680. void STDCALL MDxFinalize( MDxSum * );
  31681.  
  31682.  
  31683.  
  31684. #include "mdx.h"
  31685. #include <stdlib.h>
  31686. #include <stdio.h>
  31687. #include <string.h>
  31688.  
  31689. // READLEN % 64 must = 0
  31690. #define READLEN    1048576L // 2^20, 1MB
  31691.  
  31692. void DigestFile( char * );
  31693. void DigestString();
  31694.  
  31695. void main(int argc, char *argv[])
  31696. {
  31697.     printf("%s\n\n", MDxGetVersion());
  31698.  
  31699.     if( argc > 1 )
  31700.         DigestFile( argv[1] );
  31701.     else    
  31702.         DigestString();
  31703.  
  31704. }
  31705.  
  31706. /*
  31707.     I use the 'chunk' method for processing files not because of
  31708.     limitations of my dll, but think what would happen if you
  31709.     tried to load an entire cd image into memory.
  31710. */
  31711. void DigestFile( char *szFName )
  31712. {
  31713.     FILE *file;
  31714.     void *lpData;
  31715.     long flen, mlen;
  31716.     MDxSum mdDataSum;
  31717.     MDxSum md4DataSum;
  31718.  
  31719.     // the 64 is for padding purposes
  31720.     lpData = malloc( READLEN + 64 );
  31721.     
  31722.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  31723.  
  31724.     file = fopen( szFName, "rb" );
  31725.     if( file == NULL )
  31726.     {
  31727.         printf("ERROR: File not found.\n");
  31728.         return;
  31729.     }
  31730.     
  31731.     MDxInit( &mdDataSum );
  31732.     MDxInit( &md4DataSum );
  31733.     
  31734.     fseek( file, 0, SEEK_END );
  31735.     //Get the file length
  31736.     flen = mlen = ftell( file );
  31737.     fseek( file, 0, SEEK_SET );
  31738.     
  31739.     // When it takes a while to process a large file,
  31740.     // remember that for each chunk it has to run 
  31741.     // through the main translation loop 16384 times!
  31742.         
  31743.     printf("Processing %ld byte file: .", flen );
  31744.     
  31745.     while( flen > READLEN )
  31746.     {
  31747.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  31748.         {
  31749.             printf("READ ERROR!\n");
  31750.             return;
  31751.         }
  31752.         MD5Translate( lpData, READLEN, &mdDataSum );
  31753.         MD4Translate( lpData, READLEN, &md4DataSum );
  31754.         flen -= READLEN;
  31755.         printf(".");
  31756.     }
  31757.  
  31758.     if (fread( lpData, 1, flen, file ) != flen)
  31759.     {
  31760.         printf("READ ERROR!\n");
  31761.         return;
  31762.     }
  31763.     // This is why I added the new argument to MDxPad
  31764.     // So we can pass the length of the data AND the
  31765.     // Total length of the message
  31766.     // Also it now returns the # of padding bytes added,
  31767.     // this is for files that are an exact multiple of the chunk
  31768.     // length. (Otherwise the padding isn't Translated)
  31769.     flen += MDxPad( lpData, flen, mlen );
  31770.     MD5Translate( lpData, flen, &mdDataSum );    
  31771.     MD4Translate( lpData, flen, &md4DataSum );
  31772.  
  31773.     // New step necessary because of the 'chunking' method
  31774.     MDxFinalize( &mdDataSum );
  31775.     MDxFinalize( &md4DataSum );
  31776.     
  31777.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31778.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31779.     fclose(file);
  31780.         
  31781. }
  31782.  
  31783. void DigestString()
  31784. {
  31785.     
  31786.     //For our demo purposes, no strings bigger than 1024 :)
  31787.     unsigned char lpData[1024] = "";
  31788.     long len = 0;
  31789.     MDxSum mdDataSum;
  31790.  
  31791.     printf("Enter the string to digest: ");
  31792.     scanf("%s", &lpData );
  31793.     len = strlen(lpData);
  31794.     
  31795.     // Have to do this before the Padding...well...it's best anyway;)
  31796.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31797.     
  31798.     // For the strings, we're gonna pad and digest the string
  31799.     // in one pass.
  31800.     MDxInit( &mdDataSum );
  31801.     MDxPad( lpData, len, len );
  31802.     
  31803.     MD5Translate( lpData, len, &mdDataSum );
  31804.         // New step necessary because of the 'chunking' method
  31805.         MDxFinalize( &mdDataSum );
  31806.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31807.     
  31808.     MDxInit( &mdDataSum );
  31809.     MD4Translate( lpData, len, &mdDataSum );    
  31810.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31811.  
  31812.     return;
  31813. }
  31814.  
  31815.  
  31816. -------------- Include
  31817.  
  31818. #ifndef __windows_h__
  31819.         typedef unsigned long DWORD;
  31820.         #define STDCALL _stdcall
  31821. #endif
  31822.  
  31823. typedef struct 
  31824. {
  31825.     DWORD dwSum[4];
  31826. }MDxSum;
  31827.  
  31828. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31829. void STDCALL MDxInit( MDxSum * );
  31830. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31831. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31832. const char * STDCALL MDxGetVersion();
  31833. void STDCALL MDxFinalize( MDxSum * );
  31834.  
  31835.  
  31836.  
  31837. #include "mdx.h"
  31838. #include <stdlib.h>
  31839. #include <stdio.h>
  31840. #include <string.h>
  31841.  
  31842. // READLEN % 64 must = 0
  31843. #define READLEN    1048576L // 2^20, 1MB
  31844.  
  31845. void DigestFile( char * );
  31846. void DigestString();
  31847.  
  31848. void main(int argc, char *argv[])
  31849. {
  31850.     printf("%s\n\n", MDxGetVersion());
  31851.  
  31852.     if( argc > 1 )
  31853.         DigestFile( argv[1] );
  31854.     else    
  31855.         DigestString();
  31856.  
  31857. }
  31858.  
  31859. /*
  31860.     I use the 'chunk' method for processing files not because of
  31861.     limitations of my dll, but think what would happen if you
  31862.     tried to load an entire cd image into memory.
  31863. */
  31864. void DigestFile( char *szFName )
  31865. {
  31866.     FILE *file;
  31867.     void *lpData;
  31868.     long flen, mlen;
  31869.     MDxSum mdDataSum;
  31870.     MDxSum md4DataSum;
  31871.  
  31872.     // the 64 is for padding purposes
  31873.     lpData = malloc( READLEN + 64 );
  31874.     
  31875.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  31876.  
  31877.     file = fopen( szFName, "rb" );
  31878.     if( file == NULL )
  31879.     {
  31880.         printf("ERROR: File not found.\n");
  31881.         return;
  31882.     }
  31883.     
  31884.     MDxInit( &mdDataSum );
  31885.     MDxInit( &md4DataSum );
  31886.     
  31887.     fseek( file, 0, SEEK_END );
  31888.     //Get the file length
  31889.     flen = mlen = ftell( file );
  31890.     fseek( file, 0, SEEK_SET );
  31891.     
  31892.     // When it takes a while to process a large file,
  31893.     // remember that for each chunk it has to run 
  31894.     // through the main translation loop 16384 times!
  31895.         
  31896.     printf("Processing %ld byte file: .", flen );
  31897.     
  31898.     while( flen > READLEN )
  31899.     {
  31900.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  31901.         {
  31902.             printf("READ ERROR!\n");
  31903.             return;
  31904.         }
  31905.         MD5Translate( lpData, READLEN, &mdDataSum );
  31906.         MD4Translate( lpData, READLEN, &md4DataSum );
  31907.         flen -= READLEN;
  31908.         printf(".");
  31909.     }
  31910.  
  31911.     if (fread( lpData, 1, flen, file ) != flen)
  31912.     {
  31913.         printf("READ ERROR!\n");
  31914.         return;
  31915.     }
  31916.     // This is why I added the new argument to MDxPad
  31917.     // So we can pass the length of the data AND the
  31918.     // Total length of the message
  31919.     // Also it now returns the # of padding bytes added,
  31920.     // this is for files that are an exact multiple of the chunk
  31921.     // length. (Otherwise the padding isn't Translated)
  31922.     flen += MDxPad( lpData, flen, mlen );
  31923.     MD5Translate( lpData, flen, &mdDataSum );    
  31924.     MD4Translate( lpData, flen, &md4DataSum );
  31925.  
  31926.     // New step necessary because of the 'chunking' method
  31927.     MDxFinalize( &mdDataSum );
  31928.     MDxFinalize( &md4DataSum );
  31929.     
  31930.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  31931.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31932.     fclose(file);
  31933.         
  31934. }
  31935.  
  31936. void DigestString()
  31937. {
  31938.     
  31939.     //For our demo purposes, no strings bigger than 1024 :)
  31940.     unsigned char lpData[1024] = "";
  31941.     long len = 0;
  31942.     MDxSum mdDataSum;
  31943.  
  31944.     printf("Enter the string to digest: ");
  31945.     scanf("%s", &lpData );
  31946.     len = strlen(lpData);
  31947.     
  31948.     // Have to do this before the Padding...well...it's best anyway;)
  31949.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  31950.     
  31951.     // For the strings, we're gonna pad and digest the string
  31952.     // in one pass.
  31953.     MDxInit( &mdDataSum );
  31954.     MDxPad( lpData, len, len );
  31955.     
  31956.     MD5Translate( lpData, len, &mdDataSum );
  31957.         // New step necessary because of the 'chunking' method
  31958.         MDxFinalize( &mdDataSum );
  31959.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31960.     
  31961.     MDxInit( &mdDataSum );
  31962.     MD4Translate( lpData, len, &mdDataSum );    
  31963.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  31964.  
  31965.     return;
  31966. }
  31967.  
  31968.  
  31969. -------------- Include
  31970.  
  31971. #ifndef __windows_h__
  31972.         typedef unsigned long DWORD;
  31973.         #define STDCALL _stdcall
  31974. #endif
  31975.  
  31976. typedef struct 
  31977. {
  31978.     DWORD dwSum[4];
  31979. }MDxSum;
  31980.  
  31981. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  31982. void STDCALL MDxInit( MDxSum * );
  31983. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  31984. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  31985. const char * STDCALL MDxGetVersion();
  31986. void STDCALL MDxFinalize( MDxSum * );
  31987.  
  31988.  
  31989.  
  31990.  
  31991. #include "mdx.h"
  31992. #include <stdlib.h>
  31993. #include <stdio.h>
  31994. #include <string.h>
  31995.  
  31996. // READLEN % 64 must = 0
  31997. #define READLEN    1048576L // 2^20, 1MB
  31998.  
  31999. void DigestFile( char * );
  32000. void DigestString();
  32001.  
  32002. void main(int argc, char *argv[])
  32003. {
  32004.     printf("%s\n\n", MDxGetVersion());
  32005.  
  32006.     if( argc > 1 )
  32007.         DigestFile( argv[1] );
  32008.     else    
  32009.         DigestString();
  32010.  
  32011. }
  32012.  
  32013. /*
  32014.     I use the 'chunk' method for processing files not because of
  32015.     limitations of my dll, but think what would happen if you
  32016.     tried to load an entire cd image into memory.
  32017. */
  32018. void DigestFile( char *szFName )
  32019. {
  32020.     FILE *file;
  32021.     void *lpData;
  32022.     long flen, mlen;
  32023.     MDxSum mdDataSum;
  32024.     MDxSum md4DataSum;
  32025.  
  32026.     // the 64 is for padding purposes
  32027.     lpData = malloc( READLEN + 64 );
  32028.     
  32029.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32030.  
  32031.     file = fopen( szFName, "rb" );
  32032.     if( file == NULL )
  32033.     {
  32034.         printf("ERROR: File not found.\n");
  32035.         return;
  32036.     }
  32037.     
  32038.     MDxInit( &mdDataSum );
  32039.     MDxInit( &md4DataSum );
  32040.     
  32041.     fseek( file, 0, SEEK_END );
  32042.     //Get the file length
  32043.     flen = mlen = ftell( file );
  32044.     fseek( file, 0, SEEK_SET );
  32045.     
  32046.     // When it takes a while to process a large file,
  32047.     // remember that for each chunk it has to run 
  32048.     // through the main translation loop 16384 times!
  32049.         
  32050.     printf("Processing %ld byte file: .", flen );
  32051.     
  32052.     while( flen > READLEN )
  32053.     {
  32054.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32055.         {
  32056.             printf("READ ERROR!\n");
  32057.             return;
  32058.         }
  32059.         MD5Translate( lpData, READLEN, &mdDataSum );
  32060.         MD4Translate( lpData, READLEN, &md4DataSum );
  32061.         flen -= READLEN;
  32062.         printf(".");
  32063.     }
  32064.  
  32065.     if (fread( lpData, 1, flen, file ) != flen)
  32066.     {
  32067.         printf("READ ERROR!\n");
  32068.         return;
  32069.     }
  32070.     // This is why I added the new argument to MDxPad
  32071.     // So we can pass the length of the data AND the
  32072.     // Total length of the message
  32073.     // Also it now returns the # of padding bytes added,
  32074.     // this is for files that are an exact multiple of the chunk
  32075.     // length. (Otherwise the padding isn't Translated)
  32076.     flen += MDxPad( lpData, flen, mlen );
  32077.     MD5Translate( lpData, flen, &mdDataSum );    
  32078.     MD4Translate( lpData, flen, &md4DataSum );
  32079.  
  32080.     // New step necessary because of the 'chunking' method
  32081.     MDxFinalize( &mdDataSum );
  32082.     MDxFinalize( &md4DataSum );
  32083.     
  32084.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  32085.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32086.     fclose(file);
  32087.         
  32088. }
  32089.  
  32090. void DigestString()
  32091. {
  32092.     
  32093.     //For our demo purposes, no strings bigger than 1024 :)
  32094.     unsigned char lpData[1024] = "";
  32095.     long len = 0;
  32096.     MDxSum mdDataSum;
  32097.  
  32098.     printf("Enter the string to digest: ");
  32099.     scanf("%s", &lpData );
  32100.     len = strlen(lpData);
  32101.     
  32102.     // Have to do this before the Padding...well...it's best anyway;)
  32103.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  32104.     
  32105.     // For the strings, we're gonna pad and digest the string
  32106.     // in one pass.
  32107.     MDxInit( &mdDataSum );
  32108.     MDxPad( lpData, len, len );
  32109.     
  32110.     MD5Translate( lpData, len, &mdDataSum );
  32111.         // New step necessary because of the 'chunking' method
  32112.         MDxFinalize( &mdDataSum );
  32113.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32114.     
  32115.     MDxInit( &mdDataSum );
  32116.     MD4Translate( lpData, len, &mdDataSum );    
  32117.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32118.  
  32119.     return;
  32120. }
  32121.  
  32122.  
  32123. -------------- Include
  32124.  
  32125. #ifndef __windows_h__
  32126.         typedef unsigned long DWORD;
  32127.         #define STDCALL _stdcall
  32128. #endif
  32129.  
  32130. typedef struct 
  32131. {
  32132.     DWORD dwSum[4];
  32133. }MDxSum;
  32134.  
  32135. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  32136. void STDCALL MDxInit( MDxSum * );
  32137. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  32138. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  32139. const char * STDCALL MDxGetVersion();
  32140. void STDCALL MDxFinalize( MDxSum * );
  32141.  
  32142.  
  32143.  
  32144.  
  32145. #include "mdx.h"
  32146. #include <stdlib.h>
  32147. #include <stdio.h>
  32148. #include <string.h>
  32149.  
  32150. // READLEN % 64 must = 0
  32151. #define READLEN    1048576L // 2^20, 1MB
  32152.  
  32153. void DigestFile( char * );
  32154. void DigestString();
  32155.  
  32156. void main(int argc, char *argv[])
  32157. {
  32158.     printf("%s\n\n", MDxGetVersion());
  32159.  
  32160.     if( argc > 1 )
  32161.         DigestFile( argv[1] );
  32162.     else    
  32163.         DigestString();
  32164.  
  32165. }
  32166.  
  32167. /*
  32168.     I use the 'chunk' method for processing files not because of
  32169.     limitations of my dll, but think what would happen if you
  32170.     tried to load an entire cd image into memory.
  32171. */
  32172. void DigestFile( char *szFName )
  32173. {
  32174.     FILE *file;
  32175.     void *lpData;
  32176.     long flen, mlen;
  32177.     MDxSum mdDataSum;
  32178.     MDxSum md4DataSum;
  32179.  
  32180.     // the 64 is for padding purposes
  32181.     lpData = malloc( READLEN + 64 );
  32182.     
  32183.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32184.  
  32185.     file = fopen( szFName, "rb" );
  32186.     if( file == NULL )
  32187.     {
  32188.         printf("ERROR: File not found.\n");
  32189.         return;
  32190.     }
  32191.     
  32192.     MDxInit( &mdDataSum );
  32193.     MDxInit( &md4DataSum );
  32194.     
  32195.     fseek( file, 0, SEEK_END );
  32196.     //Get the file length
  32197.     flen = mlen = ftell( file );
  32198.     fseek( file, 0, SEEK_SET );
  32199.     
  32200.     // When it takes a while to process a large file,
  32201.     // remember that for each chunk it has to run 
  32202.     // through the main translation loop 16384 times!
  32203.         
  32204.     printf("Processing %ld byte file: .", flen );
  32205.     
  32206.     while( flen > READLEN )
  32207.     {
  32208.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32209.         {
  32210.             printf("READ ERROR!\n");
  32211.             return;
  32212.         }
  32213.         MD5Translate( lpData, READLEN, &mdDataSum );
  32214.         MD4Translate( lpData, READLEN, &md4DataSum );
  32215.         flen -= READLEN;
  32216.         printf(".");
  32217.     }
  32218.  
  32219.     if (fread( lpData, 1, flen, file ) != flen)
  32220.     {
  32221.         printf("READ ERROR!\n");
  32222.         return;
  32223.     }
  32224.     // This is why I added the new argument to MDxPad
  32225.     // So we can pass the length of the data AND the
  32226.     // Total length of the message
  32227.     // Also it now returns the # of padding bytes added,
  32228.     // this is for files that are an exact multiple of the chunk
  32229.     // length. (Otherwise the padding isn't Translated)
  32230.     flen += MDxPad( lpData, flen, mlen );
  32231.     MD5Translate( lpData, flen, &mdDataSum );    
  32232.     MD4Translate( lpData, flen, &md4DataSum );
  32233.  
  32234.     // New step necessary because of the 'chunking' method
  32235.     MDxFinalize( &mdDataSum );
  32236.     MDxFinalize( &md4DataSum );
  32237.     
  32238.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  32239.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32240.     fclose(file);
  32241.         
  32242. }
  32243.  
  32244. void DigestString()
  32245. {
  32246.     
  32247.     //For our demo purposes, no strings bigger than 1024 :)
  32248.     unsigned char lpData[1024] = "";
  32249.     long len = 0;
  32250.     MDxSum mdDataSum;
  32251.  
  32252.     printf("Enter the string to digest: ");
  32253.     scanf("%s", &lpData );
  32254.     len = strlen(lpData);
  32255.     
  32256.     // Have to do this before the Padding...well...it's best anyway;)
  32257.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  32258.     
  32259.     // For the strings, we're gonna pad and digest the string
  32260.     // in one pass.
  32261.     MDxInit( &mdDataSum );
  32262.     MDxPad( lpData, len, len );
  32263.     
  32264.     MD5Translate( lpData, len, &mdDataSum );
  32265.         // New step necessary because of the 'chunking' method
  32266.         MDxFinalize( &mdDataSum );
  32267.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32268.     
  32269.     MDxInit( &mdDataSum );
  32270.     MD4Translate( lpData, len, &mdDataSum );    
  32271.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32272.  
  32273.     return;
  32274. }
  32275.  
  32276.  
  32277. -------------- Include
  32278.  
  32279. #ifndef __windows_h__
  32280.         typedef unsigned long DWORD;
  32281.         #define STDCALL _stdcall
  32282. #endif
  32283.  
  32284. typedef struct 
  32285. {
  32286.     DWORD dwSum[4];
  32287. }MDxSum;
  32288.  
  32289. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  32290. void STDCALL MDxInit( MDxSum * );
  32291. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  32292. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  32293. const char * STDCALL MDxGetVersion();
  32294. void STDCALL MDxFinalize( MDxSum * );
  32295.  
  32296.  
  32297.  
  32298.  
  32299. #include "mdx.h"
  32300. #include <stdlib.h>
  32301. #include <stdio.h>
  32302. #include <string.h>
  32303.  
  32304. // READLEN % 64 must = 0
  32305. #define READLEN    1048576L // 2^20, 1MB
  32306.  
  32307. void DigestFile( char * );
  32308. void DigestString();
  32309.  
  32310. void main(int argc, char *argv[])
  32311. {
  32312.     printf("%s\n\n", MDxGetVersion());
  32313.  
  32314.     if( argc > 1 )
  32315.         DigestFile( argv[1] );
  32316.     else    
  32317.         DigestString();
  32318.  
  32319. }
  32320.  
  32321. /*
  32322.     I use the 'chunk' method for processing files not because of
  32323.     limitations of my dll, but think what would happen if you
  32324.     tried to load an entire cd image into memory.
  32325. */
  32326. void DigestFile( char *szFName )
  32327. {
  32328.     FILE *file;
  32329.     void *lpData;
  32330.     long flen, mlen;
  32331.     MDxSum mdDataSum;
  32332.     MDxSum md4DataSum;
  32333.  
  32334.     // the 64 is for padding purposes
  32335.     lpData = malloc( READLEN + 64 );
  32336.     
  32337.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32338.  
  32339.     file = fopen( szFName, "rb" );
  32340.     if( file == NULL )
  32341.     {
  32342.         printf("ERROR: File not found.\n");
  32343.         return;
  32344.     }
  32345.     
  32346.     MDxInit( &mdDataSum );
  32347.     MDxInit( &md4DataSum );
  32348.     
  32349.     fseek( file, 0, SEEK_END );
  32350.     //Get the file length
  32351.     flen = mlen = ftell( file );
  32352.     fseek( file, 0, SEEK_SET );
  32353.     
  32354.     // When it takes a while to process a large file,
  32355.     // remember that for each chunk it has to run 
  32356.     // through the main translation loop 16384 times!
  32357.         
  32358.     printf("Processing %ld byte file: .", flen );
  32359.     
  32360.     while( flen > READLEN )
  32361.     {
  32362.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32363.         {
  32364.             printf("READ ERROR!\n");
  32365.             return;
  32366.         }
  32367.         MD5Translate( lpData, READLEN, &mdDataSum );
  32368.         MD4Translate( lpData, READLEN, &md4DataSum );
  32369.         flen -= READLEN;
  32370.         printf(".");
  32371.     }
  32372.  
  32373.     if (fread( lpData, 1, flen, file ) != flen)
  32374.     {
  32375.         printf("READ ERROR!\n");
  32376.         return;
  32377.     }
  32378.     // This is why I added the new argument to MDxPad
  32379.     // So we can pass the length of the data AND the
  32380.     // Total length of the message
  32381.     // Also it now returns the # of padding bytes added,
  32382.     // this is for files that are an exact multiple of the chunk
  32383.     // length. (Otherwise the padding isn't Translated)
  32384.     flen += MDxPad( lpData, flen, mlen );
  32385.     MD5Translate( lpData, flen, &mdDataSum );    
  32386.     MD4Translate( lpData, flen, &md4DataSum );
  32387.  
  32388.     // New step necessary because of the 'chunking' method
  32389.     MDxFinalize( &mdDataSum );
  32390.     MDxFinalize( &md4DataSum );
  32391.     
  32392.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  32393.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32394.     fclose(file);
  32395.         
  32396. }
  32397.  
  32398. void DigestString()
  32399. {
  32400.     
  32401.     //For our demo purposes, no strings bigger than 1024 :)
  32402.     unsigned char lpData[1024] = "";
  32403.     long len = 0;
  32404.     MDxSum mdDataSum;
  32405.  
  32406.     printf("Enter the string to digest: ");
  32407.     scanf("%s", &lpData );
  32408.     len = strlen(lpData);
  32409.     
  32410.     // Have to do this before the Padding...well...it's best anyway;)
  32411.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  32412.     
  32413.     // For the strings, we're gonna pad and digest the string
  32414.     // in one pass.
  32415.     MDxInit( &mdDataSum );
  32416.     MDxPad( lpData, len, len );
  32417.     
  32418.     MD5Translate( lpData, len, &mdDataSum );
  32419.         // New step necessary because of the 'chunking' method
  32420.         MDxFinalize( &mdDataSum );
  32421.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32422.     
  32423.     MDxInit( &mdDataSum );
  32424.     MD4Translate( lpData, len, &mdDataSum );    
  32425.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32426.  
  32427.     return;
  32428. }
  32429.  
  32430.  
  32431. -------------- Include
  32432.  
  32433. #ifndef __windows_h__
  32434.         typedef unsigned long DWORD;
  32435.         #define STDCALL _stdcall
  32436. #endif
  32437.  
  32438. typedef struct 
  32439. {
  32440.     DWORD dwSum[4];
  32441. }MDxSum;
  32442.  
  32443. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  32444. void STDCALL MDxInit( MDxSum * );
  32445. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  32446. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  32447. const char * STDCALL MDxGetVersion();
  32448. void STDCALL MDxFinalize( MDxSum * );
  32449.  
  32450.  
  32451.  
  32452. #include "mdx.h"
  32453. #include <stdlib.h>
  32454. #include <stdio.h>
  32455. #include <string.h>
  32456.  
  32457. // READLEN % 64 must = 0
  32458. #define READLEN    1048576L // 2^20, 1MB
  32459.  
  32460. void DigestFile( char * );
  32461. void DigestString();
  32462.  
  32463. void main(int argc, char *argv[])
  32464. {
  32465.     printf("%s\n\n", MDxGetVersion());
  32466.  
  32467.     if( argc > 1 )
  32468.         DigestFile( argv[1] );
  32469.     else    
  32470.         DigestString();
  32471.  
  32472. }
  32473.  
  32474. /*
  32475.     I use the 'chunk' method for processing files not because of
  32476.     limitations of my dll, but think what would happen if you
  32477.     tried to load an entire cd image into memory.
  32478. */
  32479. void DigestFile( char *szFName )
  32480. {
  32481.     FILE *file;
  32482.     void *lpData;
  32483.     long flen, mlen;
  32484.     MDxSum mdDataSum;
  32485.     MDxSum md4DataSum;
  32486.  
  32487.     // the 64 is for padding purposes
  32488.     lpData = malloc( READLEN + 64 );
  32489.     
  32490.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32491.  
  32492.     file = fopen( szFName, "rb" );
  32493.     if( file == NULL )
  32494.     {
  32495.         printf("ERROR: File not found.\n");
  32496.         return;
  32497.     }
  32498.     
  32499.     MDxInit( &mdDataSum );
  32500.     MDxInit( &md4DataSum );
  32501.     
  32502.     fseek( file, 0, SEEK_END );
  32503.     //Get the file length
  32504.     flen = mlen = ftell( file );
  32505.     fseek( file, 0, SEEK_SET );
  32506.     
  32507.     // When it takes a while to process a large file,
  32508.     // remember that for each chunk it has to run 
  32509.     // through the main translation loop 16384 times!
  32510.         
  32511.     printf("Processing %ld byte file: .", flen );
  32512.     
  32513.     while( flen > READLEN )
  32514.     {
  32515.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32516.         {
  32517.             printf("READ ERROR!\n");
  32518.             return;
  32519.         }
  32520.         MD5Translate( lpData, READLEN, &mdDataSum );
  32521.         MD4Translate( lpData, READLEN, &md4DataSum );
  32522.         flen -= READLEN;
  32523.         printf(".");
  32524.     }
  32525.  
  32526.     if (fread( lpData, 1, flen, file ) != flen)
  32527.     {
  32528.         printf("READ ERROR!\n");
  32529.         return;
  32530.     }
  32531.     // This is why I added the new argument to MDxPad
  32532.     // So we can pass the length of the data AND the
  32533.     // Total length of the message
  32534.     // Also it now returns the # of padding bytes added,
  32535.     // this is for files that are an exact multiple of the chunk
  32536.     // length. (Otherwise the padding isn't Translated)
  32537.     flen += MDxPad( lpData, flen, mlen );
  32538.     MD5Translate( lpData, flen, &mdDataSum );    
  32539.     MD4Translate( lpData, flen, &md4DataSum );
  32540.  
  32541.     // New step necessary because of the 'chunking' method
  32542.     MDxFinalize( &mdDataSum );
  32543.     MDxFinalize( &md4DataSum );
  32544.     
  32545.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  32546.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32547.     fclose(file);
  32548.         
  32549. }
  32550.  
  32551. void DigestString()
  32552. {
  32553.     
  32554.     //For our demo purposes, no strings bigger than 1024 :)
  32555.     unsigned char lpData[1024] = "";
  32556.     long len = 0;
  32557.     MDxSum mdDataSum;
  32558.  
  32559.     printf("Enter the string to digest: ");
  32560.     scanf("%s", &lpData );
  32561.     len = strlen(lpData);
  32562.     
  32563.     // Have to do this before the Padding...well...it's best anyway;)
  32564.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  32565.     
  32566.     // For the strings, we're gonna pad and digest the string
  32567.     // in one pass.
  32568.     MDxInit( &mdDataSum );
  32569.     MDxPad( lpData, len, len );
  32570.     
  32571.     MD5Translate( lpData, len, &mdDataSum );
  32572.         // New step necessary because of the 'chunking' method
  32573.         MDxFinalize( &mdDataSum );
  32574.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32575.     
  32576.     MDxInit( &mdDataSum );
  32577.     MD4Translate( lpData, len, &mdDataSum );    
  32578.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32579.  
  32580.     return;
  32581. }
  32582.  
  32583.  
  32584. -------------- Include
  32585.  
  32586. #ifndef __windows_h__
  32587.         typedef unsigned long DWORD;
  32588.         #define STDCALL _stdcall
  32589. #endif
  32590.  
  32591. typedef struct 
  32592. {
  32593.     DWORD dwSum[4];
  32594. }MDxSum;
  32595.  
  32596. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  32597. void STDCALL MDxInit( MDxSum * );
  32598. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  32599. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  32600. const char * STDCALL MDxGetVersion();
  32601. void STDCALL MDxFinalize( MDxSum * );
  32602.  
  32603.  
  32604.  
  32605. #include "mdx.h"
  32606. #include <stdlib.h>
  32607. #include <stdio.h>
  32608. #include <string.h>
  32609.  
  32610. // READLEN % 64 must = 0
  32611. #define READLEN    1048576L // 2^20, 1MB
  32612.  
  32613. void DigestFile( char * );
  32614. void DigestString();
  32615.  
  32616. void main(int argc, char *argv[])
  32617. {
  32618.     printf("%s\n\n", MDxGetVersion());
  32619.  
  32620.     if( argc > 1 )
  32621.         DigestFile( argv[1] );
  32622.     else    
  32623.         DigestString();
  32624.  
  32625. }
  32626.  
  32627. /*
  32628.     I use the 'chunk' method for processing files not because of
  32629.     limitations of my dll, but think what would happen if you
  32630.     tried to load an entire cd image into memory.
  32631. */
  32632. void DigestFile( char *szFName )
  32633. {
  32634.     FILE *file;
  32635.     void *lpData;
  32636.     long flen, mlen;
  32637.     MDxSum mdDataSum;
  32638.     MDxSum md4DataSum;
  32639.  
  32640.     // the 64 is for padding purposes
  32641.     lpData = malloc( READLEN + 64 );
  32642.     
  32643.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32644.  
  32645.     file = fopen( szFName, "rb" );
  32646.     if( file == NULL )
  32647.     {
  32648.         printf("ERROR: File not found.\n");
  32649.         return;
  32650.     }
  32651.     
  32652.     MDxInit( &mdDataSum );
  32653.     MDxInit( &md4DataSum );
  32654.     
  32655.     fseek( file, 0, SEEK_END );
  32656.     //Get the file length
  32657.     flen = mlen = ftell( file );
  32658.     fseek( file, 0, SEEK_SET );
  32659.     
  32660.     // When it takes a while to process a large file,
  32661.     // remember that for each chunk it has to run 
  32662.     // through the main translation loop 16384 times!
  32663.         
  32664.     printf("Processing %ld byte file: .", flen );
  32665.     
  32666.     while( flen > READLEN )
  32667.     {
  32668.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32669.         {
  32670.             printf("READ ERROR!\n");
  32671.             return;
  32672.         }
  32673.         MD5Translate( lpData, READLEN, &mdDataSum );
  32674.         MD4Translate( lpData, READLEN, &md4DataSum );
  32675.         flen -= READLEN;
  32676.         printf(".");
  32677.     }
  32678.  
  32679.     if (fread( lpData, 1, flen, file ) != flen)
  32680.     {
  32681.         printf("READ ERROR!\n");
  32682.         return;
  32683.     }
  32684.     // This is why I added the new argument to MDxPad
  32685.     // So we can pass the length of the data AND the
  32686.     // Total length of the message
  32687.     // Also it now returns the # of padding bytes added,
  32688.     // this is for files that are an exact multiple of the chunk
  32689.     // length. (Otherwise the padding isn't Translated)
  32690.     flen += MDxPad( lpData, flen, mlen );
  32691.     MD5Translate( lpData, flen, &mdDataSum );    
  32692.     MD4Translate( lpData, flen, &md4DataSum );
  32693.  
  32694.     // New step necessary because of the 'chunking' method
  32695.     MDxFinalize( &mdDataSum );
  32696.     MDxFinalize( &md4DataSum );
  32697.     
  32698.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  32699.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32700.     fclose(file);
  32701.         
  32702. }
  32703.  
  32704. void DigestString()
  32705. {
  32706.     
  32707.     //For our demo purposes, no strings bigger than 1024 :)
  32708.     unsigned char lpData[1024] = "";
  32709.     long len = 0;
  32710.     MDxSum mdDataSum;
  32711.  
  32712.     printf("Enter the string to digest: ");
  32713.     scanf("%s", &lpData );
  32714.     len = strlen(lpData);
  32715.     
  32716.     // Have to do this before the Padding...well...it's best anyway;)
  32717.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  32718.     
  32719.     // For the strings, we're gonna pad and digest the string
  32720.     // in one pass.
  32721.     MDxInit( &mdDataSum );
  32722.     MDxPad( lpData, len, len );
  32723.     
  32724.     MD5Translate( lpData, len, &mdDataSum );
  32725.         // New step necessary because of the 'chunking' method
  32726.         MDxFinalize( &mdDataSum );
  32727.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32728.     
  32729.     MDxInit( &mdDataSum );
  32730.     MD4Translate( lpData, len, &mdDataSum );    
  32731.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32732.  
  32733.     return;
  32734. }
  32735.  
  32736.  
  32737. -------------- Include
  32738.  
  32739. #ifndef __windows_h__
  32740.         typedef unsigned long DWORD;
  32741.         #define STDCALL _stdcall
  32742. #endif
  32743.  
  32744. typedef struct 
  32745. {
  32746.     DWORD dwSum[4];
  32747. }MDxSum;
  32748.  
  32749. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  32750. void STDCALL MDxInit( MDxSum * );
  32751. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  32752. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  32753. const char * STDCALL MDxGetVersion();
  32754. void STDCALL MDxFinalize( MDxSum * );
  32755.  
  32756.  
  32757.  
  32758.  
  32759. #include "mdx.h"
  32760. #include <stdlib.h>
  32761. #include <stdio.h>
  32762. #include <string.h>
  32763.  
  32764. // READLEN % 64 must = 0
  32765. #define READLEN    1048576L // 2^20, 1MB
  32766.  
  32767. void DigestFile( char * );
  32768. void DigestString();
  32769.  
  32770. void main(int argc, char *argv[])
  32771. {
  32772.     printf("%s\n\n", MDxGetVersion());
  32773.  
  32774.     if( argc > 1 )
  32775.         DigestFile( argv[1] );
  32776.     else    
  32777.         DigestString();
  32778.  
  32779. }
  32780.  
  32781. /*
  32782.     I use the 'chunk' method for processing files not because of
  32783.     limitations of my dll, but think what would happen if you
  32784.     tried to load an entire cd image into memory.
  32785. */
  32786. void DigestFile( char *szFName )
  32787. {
  32788.     FILE *file;
  32789.     void *lpData;
  32790.     long flen, mlen;
  32791.     MDxSum mdDataSum;
  32792.     MDxSum md4DataSum;
  32793.  
  32794.     // the 64 is for padding purposes
  32795.     lpData = malloc( READLEN + 64 );
  32796.     
  32797.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32798.  
  32799.     file = fopen( szFName, "rb" );
  32800.     if( file == NULL )
  32801.     {
  32802.         printf("ERROR: File not found.\n");
  32803.         return;
  32804.     }
  32805.     
  32806.     MDxInit( &mdDataSum );
  32807.     MDxInit( &md4DataSum );
  32808.     
  32809.     fseek( file, 0, SEEK_END );
  32810.     //Get the file length
  32811.     flen = mlen = ftell( file );
  32812.     fseek( file, 0, SEEK_SET );
  32813.     
  32814.     // When it takes a while to process a large file,
  32815.     // remember that for each chunk it has to run 
  32816.     // through the main translation loop 16384 times!
  32817.         
  32818.     printf("Processing %ld byte file: .", flen );
  32819.     
  32820.     while( flen > READLEN )
  32821.     {
  32822.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32823.         {
  32824.             printf("READ ERROR!\n");
  32825.             return;
  32826.         }
  32827.         MD5Translate( lpData, READLEN, &mdDataSum );
  32828.         MD4Translate( lpData, READLEN, &md4DataSum );
  32829.         flen -= READLEN;
  32830.         printf(".");
  32831.     }
  32832.  
  32833.     if (fread( lpData, 1, flen, file ) != flen)
  32834.     {
  32835.         printf("READ ERROR!\n");
  32836.         return;
  32837.     }
  32838.     // This is why I added the new argument to MDxPad
  32839.     // So we can pass the length of the data AND the
  32840.     // Total length of the message
  32841.     // Also it now returns the # of padding bytes added,
  32842.     // this is for files that are an exact multiple of the chunk
  32843.     // length. (Otherwise the padding isn't Translated)
  32844.     flen += MDxPad( lpData, flen, mlen );
  32845.     MD5Translate( lpData, flen, &mdDataSum );    
  32846.     MD4Translate( lpData, flen, &md4DataSum );
  32847.  
  32848.     // New step necessary because of the 'chunking' method
  32849.     MDxFinalize( &mdDataSum );
  32850.     MDxFinalize( &md4DataSum );
  32851.     
  32852.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  32853.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32854.     fclose(file);
  32855.         
  32856. }
  32857.  
  32858. void DigestString()
  32859. {
  32860.     
  32861.     //For our demo purposes, no strings bigger than 1024 :)
  32862.     unsigned char lpData[1024] = "";
  32863.     long len = 0;
  32864.     MDxSum mdDataSum;
  32865.  
  32866.     printf("Enter the string to digest: ");
  32867.     scanf("%s", &lpData );
  32868.     len = strlen(lpData);
  32869.     
  32870.     // Have to do this before the Padding...well...it's best anyway;)
  32871.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  32872.     
  32873.     // For the strings, we're gonna pad and digest the string
  32874.     // in one pass.
  32875.     MDxInit( &mdDataSum );
  32876.     MDxPad( lpData, len, len );
  32877.     
  32878.     MD5Translate( lpData, len, &mdDataSum );
  32879.         // New step necessary because of the 'chunking' method
  32880.         MDxFinalize( &mdDataSum );
  32881.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32882.     
  32883.     MDxInit( &mdDataSum );
  32884.     MD4Translate( lpData, len, &mdDataSum );    
  32885.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  32886.  
  32887.     return;
  32888. }
  32889.  
  32890.  
  32891. -------------- Include
  32892.  
  32893. #ifndef __windows_h__
  32894.         typedef unsigned long DWORD;
  32895.         #define STDCALL _stdcall
  32896. #endif
  32897.  
  32898. typedef struct 
  32899. {
  32900.     DWORD dwSum[4];
  32901. }MDxSum;
  32902.  
  32903. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  32904. void STDCALL MDxInit( MDxSum * );
  32905. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  32906. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  32907. const char * STDCALL MDxGetVersion();
  32908. void STDCALL MDxFinalize( MDxSum * );
  32909.  
  32910.  
  32911.  
  32912.  
  32913. #include "mdx.h"
  32914. #include <stdlib.h>
  32915. #include <stdio.h>
  32916. #include <string.h>
  32917.  
  32918. // READLEN % 64 must = 0
  32919. #define READLEN    1048576L // 2^20, 1MB
  32920.  
  32921. void DigestFile( char * );
  32922. void DigestString();
  32923.  
  32924. void main(int argc, char *argv[])
  32925. {
  32926.     printf("%s\n\n", MDxGetVersion());
  32927.  
  32928.     if( argc > 1 )
  32929.         DigestFile( argv[1] );
  32930.     else    
  32931.         DigestString();
  32932.  
  32933. }
  32934.  
  32935. /*
  32936.     I use the 'chunk' method for processing files not because of
  32937.     limitations of my dll, but think what would happen if you
  32938.     tried to load an entire cd image into memory.
  32939. */
  32940. void DigestFile( char *szFName )
  32941. {
  32942.     FILE *file;
  32943.     void *lpData;
  32944.     long flen, mlen;
  32945.     MDxSum mdDataSum;
  32946.     MDxSum md4DataSum;
  32947.  
  32948.     // the 64 is for padding purposes
  32949.     lpData = malloc( READLEN + 64 );
  32950.     
  32951.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  32952.  
  32953.     file = fopen( szFName, "rb" );
  32954.     if( file == NULL )
  32955.     {
  32956.         printf("ERROR: File not found.\n");
  32957.         return;
  32958.     }
  32959.     
  32960.     MDxInit( &mdDataSum );
  32961.     MDxInit( &md4DataSum );
  32962.     
  32963.     fseek( file, 0, SEEK_END );
  32964.     //Get the file length
  32965.     flen = mlen = ftell( file );
  32966.     fseek( file, 0, SEEK_SET );
  32967.     
  32968.     // When it takes a while to process a large file,
  32969.     // remember that for each chunk it has to run 
  32970.     // through the main translation loop 16384 times!
  32971.         
  32972.     printf("Processing %ld byte file: .", flen );
  32973.     
  32974.     while( flen > READLEN )
  32975.     {
  32976.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  32977.         {
  32978.             printf("READ ERROR!\n");
  32979.             return;
  32980.         }
  32981.         MD5Translate( lpData, READLEN, &mdDataSum );
  32982.         MD4Translate( lpData, READLEN, &md4DataSum );
  32983.         flen -= READLEN;
  32984.         printf(".");
  32985.     }
  32986.  
  32987.     if (fread( lpData, 1, flen, file ) != flen)
  32988.     {
  32989.         printf("READ ERROR!\n");
  32990.         return;
  32991.     }
  32992.     // This is why I added the new argument to MDxPad
  32993.     // So we can pass the length of the data AND the
  32994.     // Total length of the message
  32995.     // Also it now returns the # of padding bytes added,
  32996.     // this is for files that are an exact multiple of the chunk
  32997.     // length. (Otherwise the padding isn't Translated)
  32998.     flen += MDxPad( lpData, flen, mlen );
  32999.     MD5Translate( lpData, flen, &mdDataSum );    
  33000.     MD4Translate( lpData, flen, &md4DataSum );
  33001.  
  33002.     // New step necessary because of the 'chunking' method
  33003.     MDxFinalize( &mdDataSum );
  33004.     MDxFinalize( &md4DataSum );
  33005.     
  33006.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33007.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33008.     fclose(file);
  33009.         
  33010. }
  33011.  
  33012. void DigestString()
  33013. {
  33014.     
  33015.     //For our demo purposes, no strings bigger than 1024 :)
  33016.     unsigned char lpData[1024] = "";
  33017.     long len = 0;
  33018.     MDxSum mdDataSum;
  33019.  
  33020.     printf("Enter the string to digest: ");
  33021.     scanf("%s", &lpData );
  33022.     len = strlen(lpData);
  33023.     
  33024.     // Have to do this before the Padding...well...it's best anyway;)
  33025.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33026.     
  33027.     // For the strings, we're gonna pad and digest the string
  33028.     // in one pass.
  33029.     MDxInit( &mdDataSum );
  33030.     MDxPad( lpData, len, len );
  33031.     
  33032.     MD5Translate( lpData, len, &mdDataSum );
  33033.         // New step necessary because of the 'chunking' method
  33034.         MDxFinalize( &mdDataSum );
  33035.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33036.     
  33037.     MDxInit( &mdDataSum );
  33038.     MD4Translate( lpData, len, &mdDataSum );    
  33039.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33040.  
  33041.     return;
  33042. }
  33043.  
  33044.  
  33045. -------------- Include
  33046.  
  33047. #ifndef __windows_h__
  33048.         typedef unsigned long DWORD;
  33049.         #define STDCALL _stdcall
  33050. #endif
  33051.  
  33052. typedef struct 
  33053. {
  33054.     DWORD dwSum[4];
  33055. }MDxSum;
  33056.  
  33057. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33058. void STDCALL MDxInit( MDxSum * );
  33059. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33060. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33061. const char * STDCALL MDxGetVersion();
  33062. void STDCALL MDxFinalize( MDxSum * );
  33063.  
  33064.  
  33065.  
  33066.  
  33067. #include "mdx.h"
  33068. #include <stdlib.h>
  33069. #include <stdio.h>
  33070. #include <string.h>
  33071.  
  33072. // READLEN % 64 must = 0
  33073. #define READLEN    1048576L // 2^20, 1MB
  33074.  
  33075. void DigestFile( char * );
  33076. void DigestString();
  33077.  
  33078. void main(int argc, char *argv[])
  33079. {
  33080.     printf("%s\n\n", MDxGetVersion());
  33081.  
  33082.     if( argc > 1 )
  33083.         DigestFile( argv[1] );
  33084.     else    
  33085.         DigestString();
  33086.  
  33087. }
  33088.  
  33089. /*
  33090.     I use the 'chunk' method for processing files not because of
  33091.     limitations of my dll, but think what would happen if you
  33092.     tried to load an entire cd image into memory.
  33093. */
  33094. void DigestFile( char *szFName )
  33095. {
  33096.     FILE *file;
  33097.     void *lpData;
  33098.     long flen, mlen;
  33099.     MDxSum mdDataSum;
  33100.     MDxSum md4DataSum;
  33101.  
  33102.     // the 64 is for padding purposes
  33103.     lpData = malloc( READLEN + 64 );
  33104.     
  33105.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  33106.  
  33107.     file = fopen( szFName, "rb" );
  33108.     if( file == NULL )
  33109.     {
  33110.         printf("ERROR: File not found.\n");
  33111.         return;
  33112.     }
  33113.     
  33114.     MDxInit( &mdDataSum );
  33115.     MDxInit( &md4DataSum );
  33116.     
  33117.     fseek( file, 0, SEEK_END );
  33118.     //Get the file length
  33119.     flen = mlen = ftell( file );
  33120.     fseek( file, 0, SEEK_SET );
  33121.     
  33122.     // When it takes a while to process a large file,
  33123.     // remember that for each chunk it has to run 
  33124.     // through the main translation loop 16384 times!
  33125.         
  33126.     printf("Processing %ld byte file: .", flen );
  33127.     
  33128.     while( flen > READLEN )
  33129.     {
  33130.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  33131.         {
  33132.             printf("READ ERROR!\n");
  33133.             return;
  33134.         }
  33135.         MD5Translate( lpData, READLEN, &mdDataSum );
  33136.         MD4Translate( lpData, READLEN, &md4DataSum );
  33137.         flen -= READLEN;
  33138.         printf(".");
  33139.     }
  33140.  
  33141.     if (fread( lpData, 1, flen, file ) != flen)
  33142.     {
  33143.         printf("READ ERROR!\n");
  33144.         return;
  33145.     }
  33146.     // This is why I added the new argument to MDxPad
  33147.     // So we can pass the length of the data AND the
  33148.     // Total length of the message
  33149.     // Also it now returns the # of padding bytes added,
  33150.     // this is for files that are an exact multiple of the chunk
  33151.     // length. (Otherwise the padding isn't Translated)
  33152.     flen += MDxPad( lpData, flen, mlen );
  33153.     MD5Translate( lpData, flen, &mdDataSum );    
  33154.     MD4Translate( lpData, flen, &md4DataSum );
  33155.  
  33156.     // New step necessary because of the 'chunking' method
  33157.     MDxFinalize( &mdDataSum );
  33158.     MDxFinalize( &md4DataSum );
  33159.     
  33160.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33161.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33162.     fclose(file);
  33163.         
  33164. }
  33165.  
  33166. void DigestString()
  33167. {
  33168.     
  33169.     //For our demo purposes, no strings bigger than 1024 :)
  33170.     unsigned char lpData[1024] = "";
  33171.     long len = 0;
  33172.     MDxSum mdDataSum;
  33173.  
  33174.     printf("Enter the string to digest: ");
  33175.     scanf("%s", &lpData );
  33176.     len = strlen(lpData);
  33177.     
  33178.     // Have to do this before the Padding...well...it's best anyway;)
  33179.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33180.     
  33181.     // For the strings, we're gonna pad and digest the string
  33182.     // in one pass.
  33183.     MDxInit( &mdDataSum );
  33184.     MDxPad( lpData, len, len );
  33185.     
  33186.     MD5Translate( lpData, len, &mdDataSum );
  33187.         // New step necessary because of the 'chunking' method
  33188.         MDxFinalize( &mdDataSum );
  33189.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33190.     
  33191.     MDxInit( &mdDataSum );
  33192.     MD4Translate( lpData, len, &mdDataSum );    
  33193.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33194.  
  33195.     return;
  33196. }
  33197.  
  33198.  
  33199. -------------- Include
  33200.  
  33201. #ifndef __windows_h__
  33202.         typedef unsigned long DWORD;
  33203.         #define STDCALL _stdcall
  33204. #endif
  33205.  
  33206. typedef struct 
  33207. {
  33208.     DWORD dwSum[4];
  33209. }MDxSum;
  33210.  
  33211. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33212. void STDCALL MDxInit( MDxSum * );
  33213. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33214. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33215. const char * STDCALL MDxGetVersion();
  33216. void STDCALL MDxFinalize( MDxSum * );
  33217.  
  33218.  
  33219.  
  33220. #include "mdx.h"
  33221. #include <stdlib.h>
  33222. #include <stdio.h>
  33223. #include <string.h>
  33224.  
  33225. // READLEN % 64 must = 0
  33226. #define READLEN    1048576L // 2^20, 1MB
  33227.  
  33228. void DigestFile( char * );
  33229. void DigestString();
  33230.  
  33231. void main(int argc, char *argv[])
  33232. {
  33233.     printf("%s\n\n", MDxGetVersion());
  33234.  
  33235.     if( argc > 1 )
  33236.         DigestFile( argv[1] );
  33237.     else    
  33238.         DigestString();
  33239.  
  33240. }
  33241.  
  33242. /*
  33243.     I use the 'chunk' method for processing files not because of
  33244.     limitations of my dll, but think what would happen if you
  33245.     tried to load an entire cd image into memory.
  33246. */
  33247. void DigestFile( char *szFName )
  33248. {
  33249.     FILE *file;
  33250.     void *lpData;
  33251.     long flen, mlen;
  33252.     MDxSum mdDataSum;
  33253.     MDxSum md4DataSum;
  33254.  
  33255.     // the 64 is for padding purposes
  33256.     lpData = malloc( READLEN + 64 );
  33257.     
  33258.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  33259.  
  33260.     file = fopen( szFName, "rb" );
  33261.     if( file == NULL )
  33262.     {
  33263.         printf("ERROR: File not found.\n");
  33264.         return;
  33265.     }
  33266.     
  33267.     MDxInit( &mdDataSum );
  33268.     MDxInit( &md4DataSum );
  33269.     
  33270.     fseek( file, 0, SEEK_END );
  33271.     //Get the file length
  33272.     flen = mlen = ftell( file );
  33273.     fseek( file, 0, SEEK_SET );
  33274.     
  33275.     // When it takes a while to process a large file,
  33276.     // remember that for each chunk it has to run 
  33277.     // through the main translation loop 16384 times!
  33278.         
  33279.     printf("Processing %ld byte file: .", flen );
  33280.     
  33281.     while( flen > READLEN )
  33282.     {
  33283.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  33284.         {
  33285.             printf("READ ERROR!\n");
  33286.             return;
  33287.         }
  33288.         MD5Translate( lpData, READLEN, &mdDataSum );
  33289.         MD4Translate( lpData, READLEN, &md4DataSum );
  33290.         flen -= READLEN;
  33291.         printf(".");
  33292.     }
  33293.  
  33294.     if (fread( lpData, 1, flen, file ) != flen)
  33295.     {
  33296.         printf("READ ERROR!\n");
  33297.         return;
  33298.     }
  33299.     // This is why I added the new argument to MDxPad
  33300.     // So we can pass the length of the data AND the
  33301.     // Total length of the message
  33302.     // Also it now returns the # of padding bytes added,
  33303.     // this is for files that are an exact multiple of the chunk
  33304.     // length. (Otherwise the padding isn't Translated)
  33305.     flen += MDxPad( lpData, flen, mlen );
  33306.     MD5Translate( lpData, flen, &mdDataSum );    
  33307.     MD4Translate( lpData, flen, &md4DataSum );
  33308.  
  33309.     // New step necessary because of the 'chunking' method
  33310.     MDxFinalize( &mdDataSum );
  33311.     MDxFinalize( &md4DataSum );
  33312.     
  33313.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33314.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33315.     fclose(file);
  33316.         
  33317. }
  33318.  
  33319. void DigestString()
  33320. {
  33321.     
  33322.     //For our demo purposes, no strings bigger than 1024 :)
  33323.     unsigned char lpData[1024] = "";
  33324.     long len = 0;
  33325.     MDxSum mdDataSum;
  33326.  
  33327.     printf("Enter the string to digest: ");
  33328.     scanf("%s", &lpData );
  33329.     len = strlen(lpData);
  33330.     
  33331.     // Have to do this before the Padding...well...it's best anyway;)
  33332.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33333.     
  33334.     // For the strings, we're gonna pad and digest the string
  33335.     // in one pass.
  33336.     MDxInit( &mdDataSum );
  33337.     MDxPad( lpData, len, len );
  33338.     
  33339.     MD5Translate( lpData, len, &mdDataSum );
  33340.         // New step necessary because of the 'chunking' method
  33341.         MDxFinalize( &mdDataSum );
  33342.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33343.     
  33344.     MDxInit( &mdDataSum );
  33345.     MD4Translate( lpData, len, &mdDataSum );    
  33346.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33347.  
  33348.     return;
  33349. }
  33350.  
  33351.  
  33352. -------------- Include
  33353.  
  33354. #ifndef __windows_h__
  33355.         typedef unsigned long DWORD;
  33356.         #define STDCALL _stdcall
  33357. #endif
  33358.  
  33359. typedef struct 
  33360. {
  33361.     DWORD dwSum[4];
  33362. }MDxSum;
  33363.  
  33364. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33365. void STDCALL MDxInit( MDxSum * );
  33366. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33367. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33368. const char * STDCALL MDxGetVersion();
  33369. void STDCALL MDxFinalize( MDxSum * );
  33370.  
  33371.  
  33372.  
  33373. #include "mdx.h"
  33374. #include <stdlib.h>
  33375. #include <stdio.h>
  33376. #include <string.h>
  33377.  
  33378. // READLEN % 64 must = 0
  33379. #define READLEN    1048576L // 2^20, 1MB
  33380.  
  33381. void DigestFile( char * );
  33382. void DigestString();
  33383.  
  33384. void main(int argc, char *argv[])
  33385. {
  33386.     printf("%s\n\n", MDxGetVersion());
  33387.  
  33388.     if( argc > 1 )
  33389.         DigestFile( argv[1] );
  33390.     else    
  33391.         DigestString();
  33392.  
  33393. }
  33394.  
  33395. /*
  33396.     I use the 'chunk' method for processing files not because of
  33397.     limitations of my dll, but think what would happen if you
  33398.     tried to load an entire cd image into memory.
  33399. */
  33400. void DigestFile( char *szFName )
  33401. {
  33402.     FILE *file;
  33403.     void *lpData;
  33404.     long flen, mlen;
  33405.     MDxSum mdDataSum;
  33406.     MDxSum md4DataSum;
  33407.  
  33408.     // the 64 is for padding purposes
  33409.     lpData = malloc( READLEN + 64 );
  33410.     
  33411.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  33412.  
  33413.     file = fopen( szFName, "rb" );
  33414.     if( file == NULL )
  33415.     {
  33416.         printf("ERROR: File not found.\n");
  33417.         return;
  33418.     }
  33419.     
  33420.     MDxInit( &mdDataSum );
  33421.     MDxInit( &md4DataSum );
  33422.     
  33423.     fseek( file, 0, SEEK_END );
  33424.     //Get the file length
  33425.     flen = mlen = ftell( file );
  33426.     fseek( file, 0, SEEK_SET );
  33427.     
  33428.     // When it takes a while to process a large file,
  33429.     // remember that for each chunk it has to run 
  33430.     // through the main translation loop 16384 times!
  33431.         
  33432.     printf("Processing %ld byte file: .", flen );
  33433.     
  33434.     while( flen > READLEN )
  33435.     {
  33436.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  33437.         {
  33438.             printf("READ ERROR!\n");
  33439.             return;
  33440.         }
  33441.         MD5Translate( lpData, READLEN, &mdDataSum );
  33442.         MD4Translate( lpData, READLEN, &md4DataSum );
  33443.         flen -= READLEN;
  33444.         printf(".");
  33445.     }
  33446.  
  33447.     if (fread( lpData, 1, flen, file ) != flen)
  33448.     {
  33449.         printf("READ ERROR!\n");
  33450.         return;
  33451.     }
  33452.     // This is why I added the new argument to MDxPad
  33453.     // So we can pass the length of the data AND the
  33454.     // Total length of the message
  33455.     // Also it now returns the # of padding bytes added,
  33456.     // this is for files that are an exact multiple of the chunk
  33457.     // length. (Otherwise the padding isn't Translated)
  33458.     flen += MDxPad( lpData, flen, mlen );
  33459.     MD5Translate( lpData, flen, &mdDataSum );    
  33460.     MD4Translate( lpData, flen, &md4DataSum );
  33461.  
  33462.     // New step necessary because of the 'chunking' method
  33463.     MDxFinalize( &mdDataSum );
  33464.     MDxFinalize( &md4DataSum );
  33465.     
  33466.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33467.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33468.     fclose(file);
  33469.         
  33470. }
  33471.  
  33472. void DigestString()
  33473. {
  33474.     
  33475.     //For our demo purposes, no strings bigger than 1024 :)
  33476.     unsigned char lpData[1024] = "";
  33477.     long len = 0;
  33478.     MDxSum mdDataSum;
  33479.  
  33480.     printf("Enter the string to digest: ");
  33481.     scanf("%s", &lpData );
  33482.     len = strlen(lpData);
  33483.     
  33484.     // Have to do this before the Padding...well...it's best anyway;)
  33485.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33486.     
  33487.     // For the strings, we're gonna pad and digest the string
  33488.     // in one pass.
  33489.     MDxInit( &mdDataSum );
  33490.     MDxPad( lpData, len, len );
  33491.     
  33492.     MD5Translate( lpData, len, &mdDataSum );
  33493.         // New step necessary because of the 'chunking' method
  33494.         MDxFinalize( &mdDataSum );
  33495.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33496.     
  33497.     MDxInit( &mdDataSum );
  33498.     MD4Translate( lpData, len, &mdDataSum );    
  33499.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33500.  
  33501.     return;
  33502. }
  33503.  
  33504.  
  33505. -------------- Include
  33506.  
  33507. #ifndef __windows_h__
  33508.         typedef unsigned long DWORD;
  33509.         #define STDCALL _stdcall
  33510. #endif
  33511.  
  33512. typedef struct 
  33513. {
  33514.     DWORD dwSum[4];
  33515. }MDxSum;
  33516.  
  33517. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33518. void STDCALL MDxInit( MDxSum * );
  33519. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33520. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33521. const char * STDCALL MDxGetVersion();
  33522. void STDCALL MDxFinalize( MDxSum * );
  33523.  
  33524.  
  33525.  
  33526.  
  33527. #include "mdx.h"
  33528. #include <stdlib.h>
  33529. #include <stdio.h>
  33530. #include <string.h>
  33531.  
  33532. // READLEN % 64 must = 0
  33533. #define READLEN    1048576L // 2^20, 1MB
  33534.  
  33535. void DigestFile( char * );
  33536. void DigestString();
  33537.  
  33538. void main(int argc, char *argv[])
  33539. {
  33540.     printf("%s\n\n", MDxGetVersion());
  33541.  
  33542.     if( argc > 1 )
  33543.         DigestFile( argv[1] );
  33544.     else    
  33545.         DigestString();
  33546.  
  33547. }
  33548.  
  33549. /*
  33550.     I use the 'chunk' method for processing files not because of
  33551.     limitations of my dll, but think what would happen if you
  33552.     tried to load an entire cd image into memory.
  33553. */
  33554. void DigestFile( char *szFName )
  33555. {
  33556.     FILE *file;
  33557.     void *lpData;
  33558.     long flen, mlen;
  33559.     MDxSum mdDataSum;
  33560.     MDxSum md4DataSum;
  33561.  
  33562.     // the 64 is for padding purposes
  33563.     lpData = malloc( READLEN + 64 );
  33564.     
  33565.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  33566.  
  33567.     file = fopen( szFName, "rb" );
  33568.     if( file == NULL )
  33569.     {
  33570.         printf("ERROR: File not found.\n");
  33571.         return;
  33572.     }
  33573.     
  33574.     MDxInit( &mdDataSum );
  33575.     MDxInit( &md4DataSum );
  33576.     
  33577.     fseek( file, 0, SEEK_END );
  33578.     //Get the file length
  33579.     flen = mlen = ftell( file );
  33580.     fseek( file, 0, SEEK_SET );
  33581.     
  33582.     // When it takes a while to process a large file,
  33583.     // remember that for each chunk it has to run 
  33584.     // through the main translation loop 16384 times!
  33585.         
  33586.     printf("Processing %ld byte file: .", flen );
  33587.     
  33588.     while( flen > READLEN )
  33589.     {
  33590.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  33591.         {
  33592.             printf("READ ERROR!\n");
  33593.             return;
  33594.         }
  33595.         MD5Translate( lpData, READLEN, &mdDataSum );
  33596.         MD4Translate( lpData, READLEN, &md4DataSum );
  33597.         flen -= READLEN;
  33598.         printf(".");
  33599.     }
  33600.  
  33601.     if (fread( lpData, 1, flen, file ) != flen)
  33602.     {
  33603.         printf("READ ERROR!\n");
  33604.         return;
  33605.     }
  33606.     // This is why I added the new argument to MDxPad
  33607.     // So we can pass the length of the data AND the
  33608.     // Total length of the message
  33609.     // Also it now returns the # of padding bytes added,
  33610.     // this is for files that are an exact multiple of the chunk
  33611.     // length. (Otherwise the padding isn't Translated)
  33612.     flen += MDxPad( lpData, flen, mlen );
  33613.     MD5Translate( lpData, flen, &mdDataSum );    
  33614.     MD4Translate( lpData, flen, &md4DataSum );
  33615.  
  33616.     // New step necessary because of the 'chunking' method
  33617.     MDxFinalize( &mdDataSum );
  33618.     MDxFinalize( &md4DataSum );
  33619.     
  33620.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33621.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33622.     fclose(file);
  33623.         
  33624. }
  33625.  
  33626. void DigestString()
  33627. {
  33628.     
  33629.     //For our demo purposes, no strings bigger than 1024 :)
  33630.     unsigned char lpData[1024] = "";
  33631.     long len = 0;
  33632.     MDxSum mdDataSum;
  33633.  
  33634.     printf("Enter the string to digest: ");
  33635.     scanf("%s", &lpData );
  33636.     len = strlen(lpData);
  33637.     
  33638.     // Have to do this before the Padding...well...it's best anyway;)
  33639.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33640.     
  33641.     // For the strings, we're gonna pad and digest the string
  33642.     // in one pass.
  33643.     MDxInit( &mdDataSum );
  33644.     MDxPad( lpData, len, len );
  33645.     
  33646.     MD5Translate( lpData, len, &mdDataSum );
  33647.         // New step necessary because of the 'chunking' method
  33648.         MDxFinalize( &mdDataSum );
  33649.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33650.     
  33651.     MDxInit( &mdDataSum );
  33652.     MD4Translate( lpData, len, &mdDataSum );    
  33653.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33654.  
  33655.     return;
  33656. }
  33657.  
  33658.  
  33659. -------------- Include
  33660.  
  33661. #ifndef __windows_h__
  33662.         typedef unsigned long DWORD;
  33663.         #define STDCALL _stdcall
  33664. #endif
  33665.  
  33666. typedef struct 
  33667. {
  33668.     DWORD dwSum[4];
  33669. }MDxSum;
  33670.  
  33671. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33672. void STDCALL MDxInit( MDxSum * );
  33673. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33674. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33675. const char * STDCALL MDxGetVersion();
  33676. void STDCALL MDxFinalize( MDxSum * );
  33677.  
  33678.  
  33679.  
  33680. #include "mdx.h"
  33681. #include <stdlib.h>
  33682. #include <stdio.h>
  33683. #include <string.h>
  33684.  
  33685. // READLEN % 64 must = 0
  33686. #define READLEN    1048576L // 2^20, 1MB
  33687.  
  33688. void DigestFile( char * );
  33689. void DigestString();
  33690.  
  33691. void main(int argc, char *argv[])
  33692. {
  33693.     printf("%s\n\n", MDxGetVersion());
  33694.  
  33695.     if( argc > 1 )
  33696.         DigestFile( argv[1] );
  33697.     else    
  33698.         DigestString();
  33699.  
  33700. }
  33701.  
  33702. /*
  33703.     I use the 'chunk' method for processing files not because of
  33704.     limitations of my dll, but think what would happen if you
  33705.     tried to load an entire cd image into memory.
  33706. */
  33707. void DigestFile( char *szFName )
  33708. {
  33709.     FILE *file;
  33710.     void *lpData;
  33711.     long flen, mlen;
  33712.     MDxSum mdDataSum;
  33713.     MDxSum md4DataSum;
  33714.  
  33715.     // the 64 is for padding purposes
  33716.     lpData = malloc( READLEN + 64 );
  33717.     
  33718.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  33719.  
  33720.     file = fopen( szFName, "rb" );
  33721.     if( file == NULL )
  33722.     {
  33723.         printf("ERROR: File not found.\n");
  33724.         return;
  33725.     }
  33726.     
  33727.     MDxInit( &mdDataSum );
  33728.     MDxInit( &md4DataSum );
  33729.     
  33730.     fseek( file, 0, SEEK_END );
  33731.     //Get the file length
  33732.     flen = mlen = ftell( file );
  33733.     fseek( file, 0, SEEK_SET );
  33734.     
  33735.     // When it takes a while to process a large file,
  33736.     // remember that for each chunk it has to run 
  33737.     // through the main translation loop 16384 times!
  33738.         
  33739.     printf("Processing %ld byte file: .", flen );
  33740.     
  33741.     while( flen > READLEN )
  33742.     {
  33743.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  33744.         {
  33745.             printf("READ ERROR!\n");
  33746.             return;
  33747.         }
  33748.         MD5Translate( lpData, READLEN, &mdDataSum );
  33749.         MD4Translate( lpData, READLEN, &md4DataSum );
  33750.         flen -= READLEN;
  33751.         printf(".");
  33752.     }
  33753.  
  33754.     if (fread( lpData, 1, flen, file ) != flen)
  33755.     {
  33756.         printf("READ ERROR!\n");
  33757.         return;
  33758.     }
  33759.     // This is why I added the new argument to MDxPad
  33760.     // So we can pass the length of the data AND the
  33761.     // Total length of the message
  33762.     // Also it now returns the # of padding bytes added,
  33763.     // this is for files that are an exact multiple of the chunk
  33764.     // length. (Otherwise the padding isn't Translated)
  33765.     flen += MDxPad( lpData, flen, mlen );
  33766.     MD5Translate( lpData, flen, &mdDataSum );    
  33767.     MD4Translate( lpData, flen, &md4DataSum );
  33768.  
  33769.     // New step necessary because of the 'chunking' method
  33770.     MDxFinalize( &mdDataSum );
  33771.     MDxFinalize( &md4DataSum );
  33772.     
  33773.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33774.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33775.     fclose(file);
  33776.         
  33777. }
  33778.  
  33779. void DigestString()
  33780. {
  33781.     
  33782.     //For our demo purposes, no strings bigger than 1024 :)
  33783.     unsigned char lpData[1024] = "";
  33784.     long len = 0;
  33785.     MDxSum mdDataSum;
  33786.  
  33787.     printf("Enter the string to digest: ");
  33788.     scanf("%s", &lpData );
  33789.     len = strlen(lpData);
  33790.     
  33791.     // Have to do this before the Padding...well...it's best anyway;)
  33792.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33793.     
  33794.     // For the strings, we're gonna pad and digest the string
  33795.     // in one pass.
  33796.     MDxInit( &mdDataSum );
  33797.     MDxPad( lpData, len, len );
  33798.     
  33799.     MD5Translate( lpData, len, &mdDataSum );
  33800.         // New step necessary because of the 'chunking' method
  33801.         MDxFinalize( &mdDataSum );
  33802.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33803.     
  33804.     MDxInit( &mdDataSum );
  33805.     MD4Translate( lpData, len, &mdDataSum );    
  33806.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33807.  
  33808.     return;
  33809. }
  33810.  
  33811.  
  33812. -------------- Include
  33813.  
  33814. #ifndef __windows_h__
  33815.         typedef unsigned long DWORD;
  33816.         #define STDCALL _stdcall
  33817. #endif
  33818.  
  33819. typedef struct 
  33820. {
  33821.     DWORD dwSum[4];
  33822. }MDxSum;
  33823.  
  33824. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33825. void STDCALL MDxInit( MDxSum * );
  33826. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33827. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33828. const char * STDCALL MDxGetVersion();
  33829. void STDCALL MDxFinalize( MDxSum * );
  33830.  
  33831.  
  33832.  
  33833.  
  33834. #include "mdx.h"
  33835. #include <stdlib.h>
  33836. #include <stdio.h>
  33837. #include <string.h>
  33838.  
  33839. // READLEN % 64 must = 0
  33840. #define READLEN    1048576L // 2^20, 1MB
  33841.  
  33842. void DigestFile( char * );
  33843. void DigestString();
  33844.  
  33845. void main(int argc, char *argv[])
  33846. {
  33847.     printf("%s\n\n", MDxGetVersion());
  33848.  
  33849.     if( argc > 1 )
  33850.         DigestFile( argv[1] );
  33851.     else    
  33852.         DigestString();
  33853.  
  33854. }
  33855.  
  33856. /*
  33857.     I use the 'chunk' method for processing files not because of
  33858.     limitations of my dll, but think what would happen if you
  33859.     tried to load an entire cd image into memory.
  33860. */
  33861. void DigestFile( char *szFName )
  33862. {
  33863.     FILE *file;
  33864.     void *lpData;
  33865.     long flen, mlen;
  33866.     MDxSum mdDataSum;
  33867.     MDxSum md4DataSum;
  33868.  
  33869.     // the 64 is for padding purposes
  33870.     lpData = malloc( READLEN + 64 );
  33871.     
  33872.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  33873.  
  33874.     file = fopen( szFName, "rb" );
  33875.     if( file == NULL )
  33876.     {
  33877.         printf("ERROR: File not found.\n");
  33878.         return;
  33879.     }
  33880.     
  33881.     MDxInit( &mdDataSum );
  33882.     MDxInit( &md4DataSum );
  33883.     
  33884.     fseek( file, 0, SEEK_END );
  33885.     //Get the file length
  33886.     flen = mlen = ftell( file );
  33887.     fseek( file, 0, SEEK_SET );
  33888.     
  33889.     // When it takes a while to process a large file,
  33890.     // remember that for each chunk it has to run 
  33891.     // through the main translation loop 16384 times!
  33892.         
  33893.     printf("Processing %ld byte file: .", flen );
  33894.     
  33895.     while( flen > READLEN )
  33896.     {
  33897.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  33898.         {
  33899.             printf("READ ERROR!\n");
  33900.             return;
  33901.         }
  33902.         MD5Translate( lpData, READLEN, &mdDataSum );
  33903.         MD4Translate( lpData, READLEN, &md4DataSum );
  33904.         flen -= READLEN;
  33905.         printf(".");
  33906.     }
  33907.  
  33908.     if (fread( lpData, 1, flen, file ) != flen)
  33909.     {
  33910.         printf("READ ERROR!\n");
  33911.         return;
  33912.     }
  33913.     // This is why I added the new argument to MDxPad
  33914.     // So we can pass the length of the data AND the
  33915.     // Total length of the message
  33916.     // Also it now returns the # of padding bytes added,
  33917.     // this is for files that are an exact multiple of the chunk
  33918.     // length. (Otherwise the padding isn't Translated)
  33919.     flen += MDxPad( lpData, flen, mlen );
  33920.     MD5Translate( lpData, flen, &mdDataSum );    
  33921.     MD4Translate( lpData, flen, &md4DataSum );
  33922.  
  33923.     // New step necessary because of the 'chunking' method
  33924.     MDxFinalize( &mdDataSum );
  33925.     MDxFinalize( &md4DataSum );
  33926.     
  33927.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  33928.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33929.     fclose(file);
  33930.         
  33931. }
  33932.  
  33933. void DigestString()
  33934. {
  33935.     
  33936.     //For our demo purposes, no strings bigger than 1024 :)
  33937.     unsigned char lpData[1024] = "";
  33938.     long len = 0;
  33939.     MDxSum mdDataSum;
  33940.  
  33941.     printf("Enter the string to digest: ");
  33942.     scanf("%s", &lpData );
  33943.     len = strlen(lpData);
  33944.     
  33945.     // Have to do this before the Padding...well...it's best anyway;)
  33946.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  33947.     
  33948.     // For the strings, we're gonna pad and digest the string
  33949.     // in one pass.
  33950.     MDxInit( &mdDataSum );
  33951.     MDxPad( lpData, len, len );
  33952.     
  33953.     MD5Translate( lpData, len, &mdDataSum );
  33954.         // New step necessary because of the 'chunking' method
  33955.         MDxFinalize( &mdDataSum );
  33956.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33957.     
  33958.     MDxInit( &mdDataSum );
  33959.     MD4Translate( lpData, len, &mdDataSum );    
  33960.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  33961.  
  33962.     return;
  33963. }
  33964.  
  33965.  
  33966. -------------- Include
  33967.  
  33968. #ifndef __windows_h__
  33969.         typedef unsigned long DWORD;
  33970.         #define STDCALL _stdcall
  33971. #endif
  33972.  
  33973. typedef struct 
  33974. {
  33975.     DWORD dwSum[4];
  33976. }MDxSum;
  33977.  
  33978. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  33979. void STDCALL MDxInit( MDxSum * );
  33980. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  33981. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  33982. const char * STDCALL MDxGetVersion();
  33983. void STDCALL MDxFinalize( MDxSum * );
  33984.  
  33985.  
  33986.  
  33987.  
  33988. #include "mdx.h"
  33989. #include <stdlib.h>
  33990. #include <stdio.h>
  33991. #include <string.h>
  33992.  
  33993. // READLEN % 64 must = 0
  33994. #define READLEN    1048576L // 2^20, 1MB
  33995.  
  33996. void DigestFile( char * );
  33997. void DigestString();
  33998.  
  33999. void main(int argc, char *argv[])
  34000. {
  34001.     printf("%s\n\n", MDxGetVersion());
  34002.  
  34003.     if( argc > 1 )
  34004.         DigestFile( argv[1] );
  34005.     else    
  34006.         DigestString();
  34007.  
  34008. }
  34009.  
  34010. /*
  34011.     I use the 'chunk' method for processing files not because of
  34012.     limitations of my dll, but think what would happen if you
  34013.     tried to load an entire cd image into memory.
  34014. */
  34015. void DigestFile( char *szFName )
  34016. {
  34017.     FILE *file;
  34018.     void *lpData;
  34019.     long flen, mlen;
  34020.     MDxSum mdDataSum;
  34021.     MDxSum md4DataSum;
  34022.  
  34023.     // the 64 is for padding purposes
  34024.     lpData = malloc( READLEN + 64 );
  34025.     
  34026.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34027.  
  34028.     file = fopen( szFName, "rb" );
  34029.     if( file == NULL )
  34030.     {
  34031.         printf("ERROR: File not found.\n");
  34032.         return;
  34033.     }
  34034.     
  34035.     MDxInit( &mdDataSum );
  34036.     MDxInit( &md4DataSum );
  34037.     
  34038.     fseek( file, 0, SEEK_END );
  34039.     //Get the file length
  34040.     flen = mlen = ftell( file );
  34041.     fseek( file, 0, SEEK_SET );
  34042.     
  34043.     // When it takes a while to process a large file,
  34044.     // remember that for each chunk it has to run 
  34045.     // through the main translation loop 16384 times!
  34046.         
  34047.     printf("Processing %ld byte file: .", flen );
  34048.     
  34049.     while( flen > READLEN )
  34050.     {
  34051.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34052.         {
  34053.             printf("READ ERROR!\n");
  34054.             return;
  34055.         }
  34056.         MD5Translate( lpData, READLEN, &mdDataSum );
  34057.         MD4Translate( lpData, READLEN, &md4DataSum );
  34058.         flen -= READLEN;
  34059.         printf(".");
  34060.     }
  34061.  
  34062.     if (fread( lpData, 1, flen, file ) != flen)
  34063.     {
  34064.         printf("READ ERROR!\n");
  34065.         return;
  34066.     }
  34067.     // This is why I added the new argument to MDxPad
  34068.     // So we can pass the length of the data AND the
  34069.     // Total length of the message
  34070.     // Also it now returns the # of padding bytes added,
  34071.     // this is for files that are an exact multiple of the chunk
  34072.     // length. (Otherwise the padding isn't Translated)
  34073.     flen += MDxPad( lpData, flen, mlen );
  34074.     MD5Translate( lpData, flen, &mdDataSum );    
  34075.     MD4Translate( lpData, flen, &md4DataSum );
  34076.  
  34077.     // New step necessary because of the 'chunking' method
  34078.     MDxFinalize( &mdDataSum );
  34079.     MDxFinalize( &md4DataSum );
  34080.     
  34081.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34082.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34083.     fclose(file);
  34084.         
  34085. }
  34086.  
  34087. void DigestString()
  34088. {
  34089.     
  34090.     //For our demo purposes, no strings bigger than 1024 :)
  34091.     unsigned char lpData[1024] = "";
  34092.     long len = 0;
  34093.     MDxSum mdDataSum;
  34094.  
  34095.     printf("Enter the string to digest: ");
  34096.     scanf("%s", &lpData );
  34097.     len = strlen(lpData);
  34098.     
  34099.     // Have to do this before the Padding...well...it's best anyway;)
  34100.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  34101.     
  34102.     // For the strings, we're gonna pad and digest the string
  34103.     // in one pass.
  34104.     MDxInit( &mdDataSum );
  34105.     MDxPad( lpData, len, len );
  34106.     
  34107.     MD5Translate( lpData, len, &mdDataSum );
  34108.         // New step necessary because of the 'chunking' method
  34109.         MDxFinalize( &mdDataSum );
  34110.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34111.     
  34112.     MDxInit( &mdDataSum );
  34113.     MD4Translate( lpData, len, &mdDataSum );    
  34114.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34115.  
  34116.     return;
  34117. }
  34118.  
  34119.  
  34120. -------------- Include
  34121.  
  34122. #ifndef __windows_h__
  34123.         typedef unsigned long DWORD;
  34124.         #define STDCALL _stdcall
  34125. #endif
  34126.  
  34127. typedef struct 
  34128. {
  34129.     DWORD dwSum[4];
  34130. }MDxSum;
  34131.  
  34132. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  34133. void STDCALL MDxInit( MDxSum * );
  34134. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  34135. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  34136. const char * STDCALL MDxGetVersion();
  34137. void STDCALL MDxFinalize( MDxSum * );
  34138.  
  34139.  
  34140.  
  34141. #include "mdx.h"
  34142. #include <stdlib.h>
  34143. #include <stdio.h>
  34144. #include <string.h>
  34145.  
  34146. // READLEN % 64 must = 0
  34147. #define READLEN    1048576L // 2^20, 1MB
  34148.  
  34149. void DigestFile( char * );
  34150. void DigestString();
  34151.  
  34152. void main(int argc, char *argv[])
  34153. {
  34154.     printf("%s\n\n", MDxGetVersion());
  34155.  
  34156.     if( argc > 1 )
  34157.         DigestFile( argv[1] );
  34158.     else    
  34159.         DigestString();
  34160.  
  34161. }
  34162.  
  34163. /*
  34164.     I use the 'chunk' method for processing files not because of
  34165.     limitations of my dll, but think what would happen if you
  34166.     tried to load an entire cd image into memory.
  34167. */
  34168. void DigestFile( char *szFName )
  34169. {
  34170.     FILE *file;
  34171.     void *lpData;
  34172.     long flen, mlen;
  34173.     MDxSum mdDataSum;
  34174.     MDxSum md4DataSum;
  34175.  
  34176.     // the 64 is for padding purposes
  34177.     lpData = malloc( READLEN + 64 );
  34178.     
  34179.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34180.  
  34181.     file = fopen( szFName, "rb" );
  34182.     if( file == NULL )
  34183.     {
  34184.         printf("ERROR: File not found.\n");
  34185.         return;
  34186.     }
  34187.     
  34188.     MDxInit( &mdDataSum );
  34189.     MDxInit( &md4DataSum );
  34190.     
  34191.     fseek( file, 0, SEEK_END );
  34192.     //Get the file length
  34193.     flen = mlen = ftell( file );
  34194.     fseek( file, 0, SEEK_SET );
  34195.     
  34196.     // When it takes a while to process a large file,
  34197.     // remember that for each chunk it has to run 
  34198.     // through the main translation loop 16384 times!
  34199.         
  34200.     printf("Processing %ld byte file: .", flen );
  34201.     
  34202.     while( flen > READLEN )
  34203.     {
  34204.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34205.         {
  34206.             printf("READ ERROR!\n");
  34207.             return;
  34208.         }
  34209.         MD5Translate( lpData, READLEN, &mdDataSum );
  34210.         MD4Translate( lpData, READLEN, &md4DataSum );
  34211.         flen -= READLEN;
  34212.         printf(".");
  34213.     }
  34214.  
  34215.     if (fread( lpData, 1, flen, file ) != flen)
  34216.     {
  34217.         printf("READ ERROR!\n");
  34218.         return;
  34219.     }
  34220.     // This is why I added the new argument to MDxPad
  34221.     // So we can pass the length of the data AND the
  34222.     // Total length of the message
  34223.     // Also it now returns the # of padding bytes added,
  34224.     // this is for files that are an exact multiple of the chunk
  34225.     // length. (Otherwise the padding isn't Translated)
  34226.     flen += MDxPad( lpData, flen, mlen );
  34227.     MD5Translate( lpData, flen, &mdDataSum );    
  34228.     MD4Translate( lpData, flen, &md4DataSum );
  34229.  
  34230.     // New step necessary because of the 'chunking' method
  34231.     MDxFinalize( &mdDataSum );
  34232.     MDxFinalize( &md4DataSum );
  34233.     
  34234.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34235.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34236.     fclose(file);
  34237.         
  34238. }
  34239.  
  34240. void DigestString()
  34241. {
  34242.     
  34243.     //For our demo purposes, no strings bigger than 1024 :)
  34244.     unsigned char lpData[1024] = "";
  34245.     long len = 0;
  34246.     MDxSum mdDataSum;
  34247.  
  34248.     printf("Enter the string to digest: ");
  34249.     scanf("%s", &lpData );
  34250.     len = strlen(lpData);
  34251.     
  34252.     // Have to do this before the Padding...well...it's best anyway;)
  34253.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  34254.     
  34255.     // For the strings, we're gonna pad and digest the string
  34256.     // in one pass.
  34257.     MDxInit( &mdDataSum );
  34258.     MDxPad( lpData, len, len );
  34259.     
  34260.     MD5Translate( lpData, len, &mdDataSum );
  34261.         // New step necessary because of the 'chunking' method
  34262.         MDxFinalize( &mdDataSum );
  34263.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34264.     
  34265.     MDxInit( &mdDataSum );
  34266.     MD4Translate( lpData, len, &mdDataSum );    
  34267.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34268.  
  34269.     return;
  34270. }
  34271.  
  34272.  
  34273. -------------- Include
  34274.  
  34275. #ifndef __windows_h__
  34276.         typedef unsigned long DWORD;
  34277.         #define STDCALL _stdcall
  34278. #endif
  34279.  
  34280. typedef struct 
  34281. {
  34282.     DWORD dwSum[4];
  34283. }MDxSum;
  34284.  
  34285. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  34286. void STDCALL MDxInit( MDxSum * );
  34287. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  34288. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  34289. const char * STDCALL MDxGetVersion();
  34290. void STDCALL MDxFinalize( MDxSum * );
  34291.  
  34292.  
  34293. #include "mdx.h"
  34294. #include <stdlib.h>
  34295. #include <stdio.h>
  34296. #include <string.h>
  34297.  
  34298. // READLEN % 64 must = 0
  34299. #define READLEN    1048576L // 2^20, 1MB
  34300.  
  34301. void DigestFile( char * );
  34302. void DigestString();
  34303.  
  34304. void main(int argc, char *argv[])
  34305. {
  34306.     printf("%s\n\n", MDxGetVersion());
  34307.  
  34308.     if( argc > 1 )
  34309.         DigestFile( argv[1] );
  34310.     else    
  34311.         DigestString();
  34312.  
  34313. }
  34314.  
  34315. /*
  34316.     I use the 'chunk' method for processing files not because of
  34317.     limitations of my dll, but think what would happen if you
  34318.     tried to load an entire cd image into memory.
  34319. */
  34320. void DigestFile( char *szFName )
  34321. {
  34322.     FILE *file;
  34323.     void *lpData;
  34324.     long flen, mlen;
  34325.     MDxSum mdDataSum;
  34326.     MDxSum md4DataSum;
  34327.  
  34328.     // the 64 is for padding purposes
  34329.     lpData = malloc( READLEN + 64 );
  34330.     
  34331.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34332.  
  34333.     file = fopen( szFName, "rb" );
  34334.     if( file == NULL )
  34335.     {
  34336.         printf("ERROR: File not found.\n");
  34337.         return;
  34338.     }
  34339.     
  34340.     MDxInit( &mdDataSum );
  34341.     MDxInit( &md4DataSum );
  34342.     
  34343.     fseek( file, 0, SEEK_END );
  34344.     //Get the file length
  34345.     flen = mlen = ftell( file );
  34346.     fseek( file, 0, SEEK_SET );
  34347.     
  34348.     // When it takes a while to process a large file,
  34349.     // remember that for each chunk it has to run 
  34350.     // through the main translation loop 16384 times!
  34351.         
  34352.     printf("Processing %ld byte file: .", flen );
  34353.     
  34354.     while( flen > READLEN )
  34355.     {
  34356.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34357.         {
  34358.             printf("READ ERROR!\n");
  34359.             return;
  34360.         }
  34361.         MD5Translate( lpData, READLEN, &mdDataSum );
  34362.         MD4Translate( lpData, READLEN, &md4DataSum );
  34363.         flen -= READLEN;
  34364.         printf(".");
  34365.     }
  34366.  
  34367.     if (fread( lpData, 1, flen, file ) != flen)
  34368.     {
  34369.         printf("READ ERROR!\n");
  34370.         return;
  34371.     }
  34372.     // This is why I added the new argument to MDxPad
  34373.     // So we can pass the length of the data AND the
  34374.     // Total length of the message
  34375.     // Also it now returns the # of padding bytes added,
  34376.     // this is for files that are an exact multiple of the chunk
  34377.     // length. (Otherwise the padding isn't Translated)
  34378.     flen += MDxPad( lpData, flen, mlen );
  34379.     MD5Translate( lpData, flen, &mdDataSum );    
  34380.     MD4Translate( lpData, flen, &md4DataSum );
  34381.  
  34382.     // New step necessary because of the 'chunking' method
  34383.     MDxFinalize( &mdDataSum );
  34384.     MDxFinalize( &md4DataSum );
  34385.     
  34386.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34387.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34388.     fclose(file);
  34389.         
  34390. }
  34391.  
  34392. void DigestString()
  34393. {
  34394.     
  34395.     //For our demo purposes, no strings bigger than 1024 :)
  34396.     unsigned char lpData[1024] = "";
  34397.     long len = 0;
  34398.     MDxSum mdDataSum;
  34399.  
  34400.     printf("Enter the string to digest: ");
  34401.     scanf("%s", &lpData );
  34402.     len = strlen(lpData);
  34403.     
  34404.     // Have to do this before the Padding...well...it's best anyway;)
  34405.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  34406.     
  34407.     // For the strings, we're gonna pad and digest the string
  34408.     // in one pass.
  34409.     MDxInit( &mdDataSum );
  34410.     MDxPad( lpData, len, len );
  34411.     
  34412.     MD5Translate( lpData, len, &mdDataSum );
  34413.         // New step necessary because of the 'chunking' method
  34414.         MDxFinalize( &mdDataSum );
  34415.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34416.     
  34417.     MDxInit( &mdDataSum );
  34418.     MD4Translate( lpData, len, &mdDataSum );    
  34419.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34420.  
  34421.     return;
  34422. }
  34423.  
  34424.  
  34425. -------------- Include
  34426.  
  34427. #ifndef __windows_h__
  34428.         typedef unsigned long DWORD;
  34429.         #define STDCALL _stdcall
  34430. #endif
  34431.  
  34432. typedef struct 
  34433. {
  34434.     DWORD dwSum[4];
  34435. }MDxSum;
  34436.  
  34437. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  34438. void STDCALL MDxInit( MDxSum * );
  34439. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  34440. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  34441. const char * STDCALL MDxGetVersion();
  34442. void STDCALL MDxFinalize( MDxSum * );
  34443.  
  34444.  
  34445.  
  34446. #include "mdx.h"
  34447. #include <stdlib.h>
  34448. #include <stdio.h>
  34449. #include <string.h>
  34450.  
  34451. // READLEN % 64 must = 0
  34452. #define READLEN    1048576L // 2^20, 1MB
  34453.  
  34454. void DigestFile( char * );
  34455. void DigestString();
  34456.  
  34457. void main(int argc, char *argv[])
  34458. {
  34459.     printf("%s\n\n", MDxGetVersion());
  34460.  
  34461.     if( argc > 1 )
  34462.         DigestFile( argv[1] );
  34463.     else    
  34464.         DigestString();
  34465.  
  34466. }
  34467.  
  34468. /*
  34469.     I use the 'chunk' method for processing files not because of
  34470.     limitations of my dll, but think what would happen if you
  34471.     tried to load an entire cd image into memory.
  34472. */
  34473. void DigestFile( char *szFName )
  34474. {
  34475.     FILE *file;
  34476.     void *lpData;
  34477.     long flen, mlen;
  34478.     MDxSum mdDataSum;
  34479.     MDxSum md4DataSum;
  34480.  
  34481.     // the 64 is for padding purposes
  34482.     lpData = malloc( READLEN + 64 );
  34483.     
  34484.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34485.  
  34486.     file = fopen( szFName, "rb" );
  34487.     if( file == NULL )
  34488.     {
  34489.         printf("ERROR: File not found.\n");
  34490.         return;
  34491.     }
  34492.     
  34493.     MDxInit( &mdDataSum );
  34494.     MDxInit( &md4DataSum );
  34495.     
  34496.     fseek( file, 0, SEEK_END );
  34497.     //Get the file length
  34498.     flen = mlen = ftell( file );
  34499.     fseek( file, 0, SEEK_SET );
  34500.     
  34501.     // When it takes a while to process a large file,
  34502.     // remember that for each chunk it has to run 
  34503.     // through the main translation loop 16384 times!
  34504.         
  34505.     printf("Processing %ld byte file: .", flen );
  34506.     
  34507.     while( flen > READLEN )
  34508.     {
  34509.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34510.         {
  34511.             printf("READ ERROR!\n");
  34512.             return;
  34513.         }
  34514.         MD5Translate( lpData, READLEN, &mdDataSum );
  34515.         MD4Translate( lpData, READLEN, &md4DataSum );
  34516.         flen -= READLEN;
  34517.         printf(".");
  34518.     }
  34519.  
  34520.     if (fread( lpData, 1, flen, file ) != flen)
  34521.     {
  34522.         printf("READ ERROR!\n");
  34523.         return;
  34524.     }
  34525.     // This is why I added the new argument to MDxPad
  34526.     // So we can pass the length of the data AND the
  34527.     // Total length of the message
  34528.     // Also it now returns the # of padding bytes added,
  34529.     // this is for files that are an exact multiple of the chunk
  34530.     // length. (Otherwise the padding isn't Translated)
  34531.     flen += MDxPad( lpData, flen, mlen );
  34532.     MD5Translate( lpData, flen, &mdDataSum );    
  34533.     MD4Translate( lpData, flen, &md4DataSum );
  34534.  
  34535.     // New step necessary because of the 'chunking' method
  34536.     MDxFinalize( &mdDataSum );
  34537.     MDxFinalize( &md4DataSum );
  34538.     
  34539.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34540.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34541.     fclose(file);
  34542.         
  34543. }
  34544.  
  34545. void DigestString()
  34546. {
  34547.     
  34548.     //For our demo purposes, no strings bigger than 1024 :)
  34549.     unsigned char lpData[1024] = "";
  34550.     long len = 0;
  34551.     MDxSum mdDataSum;
  34552.  
  34553.     printf("Enter the string to digest: ");
  34554.     scanf("%s", &lpData );
  34555.     len = strlen(lpData);
  34556.     
  34557.     // Have to do this before the Padding...well...it's best anyway;)
  34558.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  34559.     
  34560.     // For the strings, we're gonna pad and digest the string
  34561.     // in one pass.
  34562.     MDxInit( &mdDataSum );
  34563.     MDxPad( lpData, len, len );
  34564.     
  34565.     MD5Translate( lpData, len, &mdDataSum );
  34566.         // New step necessary because of the 'chunking' method
  34567.         MDxFinalize( &mdDataSum );
  34568.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34569.     
  34570.     MDxInit( &mdDataSum );
  34571.     MD4Translate( lpData, len, &mdDataSum );    
  34572.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34573.  
  34574.     return;
  34575. }
  34576.  
  34577.  
  34578. -------------- Include
  34579.  
  34580. #ifndef __windows_h__
  34581.         typedef unsigned long DWORD;
  34582.         #define STDCALL _stdcall
  34583. #endif
  34584.  
  34585. typedef struct 
  34586. {
  34587.     DWORD dwSum[4];
  34588. }MDxSum;
  34589.  
  34590. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  34591. void STDCALL MDxInit( MDxSum * );
  34592. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  34593. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  34594. const char * STDCALL MDxGetVersion();
  34595. void STDCALL MDxFinalize( MDxSum * );
  34596.  
  34597.  
  34598.  
  34599. #include "mdx.h"
  34600. #include <stdlib.h>
  34601. #include <stdio.h>
  34602. #include <string.h>
  34603.  
  34604. // READLEN % 64 must = 0
  34605. #define READLEN    1048576L // 2^20, 1MB
  34606.  
  34607. void DigestFile( char * );
  34608. void DigestString();
  34609.  
  34610. void main(int argc, char *argv[])
  34611. {
  34612.     printf("%s\n\n", MDxGetVersion());
  34613.  
  34614.     if( argc > 1 )
  34615.         DigestFile( argv[1] );
  34616.     else    
  34617.         DigestString();
  34618.  
  34619. }
  34620.  
  34621. /*
  34622.     I use the 'chunk' method for processing files not because of
  34623.     limitations of my dll, but think what would happen if you
  34624.     tried to load an entire cd image into memory.
  34625. */
  34626. void DigestFile( char *szFName )
  34627. {
  34628.     FILE *file;
  34629.     void *lpData;
  34630.     long flen, mlen;
  34631.     MDxSum mdDataSum;
  34632.     MDxSum md4DataSum;
  34633.  
  34634.     // the 64 is for padding purposes
  34635.     lpData = malloc( READLEN + 64 );
  34636.     
  34637.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34638.  
  34639.     file = fopen( szFName, "rb" );
  34640.     if( file == NULL )
  34641.     {
  34642.         printf("ERROR: File not found.\n");
  34643.         return;
  34644.     }
  34645.     
  34646.     MDxInit( &mdDataSum );
  34647.     MDxInit( &md4DataSum );
  34648.     
  34649.     fseek( file, 0, SEEK_END );
  34650.     //Get the file length
  34651.     flen = mlen = ftell( file );
  34652.     fseek( file, 0, SEEK_SET );
  34653.     
  34654.     // When it takes a while to process a large file,
  34655.     // remember that for each chunk it has to run 
  34656.     // through the main translation loop 16384 times!
  34657.         
  34658.     printf("Processing %ld byte file: .", flen );
  34659.     
  34660.     while( flen > READLEN )
  34661.     {
  34662.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34663.         {
  34664.             printf("READ ERROR!\n");
  34665.             return;
  34666.         }
  34667.         MD5Translate( lpData, READLEN, &mdDataSum );
  34668.         MD4Translate( lpData, READLEN, &md4DataSum );
  34669.         flen -= READLEN;
  34670.         printf(".");
  34671.     }
  34672.  
  34673.     if (fread( lpData, 1, flen, file ) != flen)
  34674.     {
  34675.         printf("READ ERROR!\n");
  34676.         return;
  34677.     }
  34678.     // This is why I added the new argument to MDxPad
  34679.     // So we can pass the length of the data AND the
  34680.     // Total length of the message
  34681.     // Also it now returns the # of padding bytes added,
  34682.     // this is for files that are an exact multiple of the chunk
  34683.     // length. (Otherwise the padding isn't Translated)
  34684.     flen += MDxPad( lpData, flen, mlen );
  34685.     MD5Translate( lpData, flen, &mdDataSum );    
  34686.     MD4Translate( lpData, flen, &md4DataSum );
  34687.  
  34688.     // New step necessary because of the 'chunking' method
  34689.     MDxFinalize( &mdDataSum );
  34690.     MDxFinalize( &md4DataSum );
  34691.     
  34692.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34693.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34694.     fclose(file);
  34695.         
  34696. }
  34697.  
  34698. void DigestString()
  34699. {
  34700.     
  34701.     //For our demo purposes, no strings bigger than 1024 :)
  34702.     unsigned char lpData[1024] = "";
  34703.     long len = 0;
  34704.     MDxSum mdDataSum;
  34705.  
  34706.     printf("Enter the string to digest: ");
  34707.     scanf("%s", &lpData );
  34708.     len = strlen(lpData);
  34709.     
  34710.     // Have to do this before the Padding...well...it's best anyway;)
  34711.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  34712.     
  34713.     // For the strings, we're gonna pad and digest the string
  34714.     // in one pass.
  34715.     MDxInit( &mdDataSum );
  34716.     MDxPad( lpData, len, len );
  34717.     
  34718.     MD5Translate( lpData, len, &mdDataSum );
  34719.         // New step necessary because of the 'chunking' method
  34720.         MDxFinalize( &mdDataSum );
  34721.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34722.     
  34723.     MDxInit( &mdDataSum );
  34724.     MD4Translate( lpData, len, &mdDataSum );    
  34725.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34726.  
  34727.     return;
  34728. }
  34729.  
  34730.  
  34731. -------------- Include
  34732.  
  34733. #ifndef __windows_h__
  34734.         typedef unsigned long DWORD;
  34735.         #define STDCALL _stdcall
  34736. #endif
  34737.  
  34738. typedef struct 
  34739. {
  34740.     DWORD dwSum[4];
  34741. }MDxSum;
  34742.  
  34743. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  34744. void STDCALL MDxInit( MDxSum * );
  34745. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  34746. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  34747. const char * STDCALL MDxGetVersion();
  34748. void STDCALL MDxFinalize( MDxSum * );
  34749.  
  34750.  
  34751. #include "mdx.h"
  34752. #include <stdlib.h>
  34753. #include <stdio.h>
  34754. #include <string.h>
  34755.  
  34756. // READLEN % 64 must = 0
  34757. #define READLEN    1048576L // 2^20, 1MB
  34758.  
  34759. void DigestFile( char * );
  34760. void DigestString();
  34761.  
  34762. void main(int argc, char *argv[])
  34763. {
  34764.     printf("%s\n\n", MDxGetVersion());
  34765.  
  34766.     if( argc > 1 )
  34767.         DigestFile( argv[1] );
  34768.     else    
  34769.         DigestString();
  34770.  
  34771. }
  34772.  
  34773. /*
  34774.     I use the 'chunk' method for processing files not because of
  34775.     limitations of my dll, but think what would happen if you
  34776.     tried to load an entire cd image into memory.
  34777. */
  34778. void DigestFile( char *szFName )
  34779. {
  34780.     FILE *file;
  34781.     void *lpData;
  34782.     long flen, mlen;
  34783.     MDxSum mdDataSum;
  34784.     MDxSum md4DataSum;
  34785.  
  34786.     // the 64 is for padding purposes
  34787.     lpData = malloc( READLEN + 64 );
  34788.     
  34789.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34790.  
  34791.     file = fopen( szFName, "rb" );
  34792.     if( file == NULL )
  34793.     {
  34794.         printf("ERROR: File not found.\n");
  34795.         return;
  34796.     }
  34797.     
  34798.     MDxInit( &mdDataSum );
  34799.     MDxInit( &md4DataSum );
  34800.     
  34801.     fseek( file, 0, SEEK_END );
  34802.     //Get the file length
  34803.     flen = mlen = ftell( file );
  34804.     fseek( file, 0, SEEK_SET );
  34805.     
  34806.     // When it takes a while to process a large file,
  34807.     // remember that for each chunk it has to run 
  34808.     // through the main translation loop 16384 times!
  34809.         
  34810.     printf("Processing %ld byte file: .", flen );
  34811.     
  34812.     while( flen > READLEN )
  34813.     {
  34814.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34815.         {
  34816.             printf("READ ERROR!\n");
  34817.             return;
  34818.         }
  34819.         MD5Translate( lpData, READLEN, &mdDataSum );
  34820.         MD4Translate( lpData, READLEN, &md4DataSum );
  34821.         flen -= READLEN;
  34822.         printf(".");
  34823.     }
  34824.  
  34825.     if (fread( lpData, 1, flen, file ) != flen)
  34826.     {
  34827.         printf("READ ERROR!\n");
  34828.         return;
  34829.     }
  34830.     // This is why I added the new argument to MDxPad
  34831.     // So we can pass the length of the data AND the
  34832.     // Total length of the message
  34833.     // Also it now returns the # of padding bytes added,
  34834.     // this is for files that are an exact multiple of the chunk
  34835.     // length. (Otherwise the padding isn't Translated)
  34836.     flen += MDxPad( lpData, flen, mlen );
  34837.     MD5Translate( lpData, flen, &mdDataSum );    
  34838.     MD4Translate( lpData, flen, &md4DataSum );
  34839.  
  34840.     // New step necessary because of the 'chunking' method
  34841.     MDxFinalize( &mdDataSum );
  34842.     MDxFinalize( &md4DataSum );
  34843.     
  34844.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34845.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34846.     fclose(file);
  34847.         
  34848. }
  34849.  
  34850. void DigestString()
  34851. {
  34852.     
  34853.     //For our demo purposes, no strings bigger than 1024 :)
  34854.     unsigned char lpData[1024] = "";
  34855.     long len = 0;
  34856.     MDxSum mdDataSum;
  34857.  
  34858.     printf("Enter the string to digest: ");
  34859.     scanf("%s", &lpData );
  34860.     len = strlen(lpData);
  34861.     
  34862.     // Have to do this before the Padding...well...it's best anyway;)
  34863.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  34864.     
  34865.     // For the strings, we're gonna pad and digest the string
  34866.     // in one pass.
  34867.     MDxInit( &mdDataSum );
  34868.     MDxPad( lpData, len, len );
  34869.     
  34870.     MD5Translate( lpData, len, &mdDataSum );
  34871.         // New step necessary because of the 'chunking' method
  34872.         MDxFinalize( &mdDataSum );
  34873.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34874.     
  34875.     MDxInit( &mdDataSum );
  34876.     MD4Translate( lpData, len, &mdDataSum );    
  34877.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34878.  
  34879.     return;
  34880. }
  34881.  
  34882.  
  34883. -------------- Include
  34884.  
  34885. #ifndef __windows_h__
  34886.         typedef unsigned long DWORD;
  34887.         #define STDCALL _stdcall
  34888. #endif
  34889.  
  34890. typedef struct 
  34891. {
  34892.     DWORD dwSum[4];
  34893. }MDxSum;
  34894.  
  34895. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  34896. void STDCALL MDxInit( MDxSum * );
  34897. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  34898. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  34899. const char * STDCALL MDxGetVersion();
  34900. void STDCALL MDxFinalize( MDxSum * );
  34901.  
  34902.  
  34903. #include "mdx.h"
  34904. #include <stdlib.h>
  34905. #include <stdio.h>
  34906. #include <string.h>
  34907.  
  34908. // READLEN % 64 must = 0
  34909. #define READLEN    1048576L // 2^20, 1MB
  34910.  
  34911. void DigestFile( char * );
  34912. void DigestString();
  34913.  
  34914. void main(int argc, char *argv[])
  34915. {
  34916.     printf("%s\n\n", MDxGetVersion());
  34917.  
  34918.     if( argc > 1 )
  34919.         DigestFile( argv[1] );
  34920.     else    
  34921.         DigestString();
  34922.  
  34923. }
  34924.  
  34925. /*
  34926.     I use the 'chunk' method for processing files not because of
  34927.     limitations of my dll, but think what would happen if you
  34928.     tried to load an entire cd image into memory.
  34929. */
  34930. void DigestFile( char *szFName )
  34931. {
  34932.     FILE *file;
  34933.     void *lpData;
  34934.     long flen, mlen;
  34935.     MDxSum mdDataSum;
  34936.     MDxSum md4DataSum;
  34937.  
  34938.     // the 64 is for padding purposes
  34939.     lpData = malloc( READLEN + 64 );
  34940.     
  34941.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  34942.  
  34943.     file = fopen( szFName, "rb" );
  34944.     if( file == NULL )
  34945.     {
  34946.         printf("ERROR: File not found.\n");
  34947.         return;
  34948.     }
  34949.     
  34950.     MDxInit( &mdDataSum );
  34951.     MDxInit( &md4DataSum );
  34952.     
  34953.     fseek( file, 0, SEEK_END );
  34954.     //Get the file length
  34955.     flen = mlen = ftell( file );
  34956.     fseek( file, 0, SEEK_SET );
  34957.     
  34958.     // When it takes a while to process a large file,
  34959.     // remember that for each chunk it has to run 
  34960.     // through the main translation loop 16384 times!
  34961.         
  34962.     printf("Processing %ld byte file: .", flen );
  34963.     
  34964.     while( flen > READLEN )
  34965.     {
  34966.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  34967.         {
  34968.             printf("READ ERROR!\n");
  34969.             return;
  34970.         }
  34971.         MD5Translate( lpData, READLEN, &mdDataSum );
  34972.         MD4Translate( lpData, READLEN, &md4DataSum );
  34973.         flen -= READLEN;
  34974.         printf(".");
  34975.     }
  34976.  
  34977.     if (fread( lpData, 1, flen, file ) != flen)
  34978.     {
  34979.         printf("READ ERROR!\n");
  34980.         return;
  34981.     }
  34982.     // This is why I added the new argument to MDxPad
  34983.     // So we can pass the length of the data AND the
  34984.     // Total length of the message
  34985.     // Also it now returns the # of padding bytes added,
  34986.     // this is for files that are an exact multiple of the chunk
  34987.     // length. (Otherwise the padding isn't Translated)
  34988.     flen += MDxPad( lpData, flen, mlen );
  34989.     MD5Translate( lpData, flen, &mdDataSum );    
  34990.     MD4Translate( lpData, flen, &md4DataSum );
  34991.  
  34992.     // New step necessary because of the 'chunking' method
  34993.     MDxFinalize( &mdDataSum );
  34994.     MDxFinalize( &md4DataSum );
  34995.     
  34996.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  34997.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  34998.     fclose(file);
  34999.         
  35000. }
  35001.  
  35002. void DigestString()
  35003. {
  35004.     
  35005.     //For our demo purposes, no strings bigger than 1024 :)
  35006.     unsigned char lpData[1024] = "";
  35007.     long len = 0;
  35008.     MDxSum mdDataSum;
  35009.  
  35010.     printf("Enter the string to digest: ");
  35011.     scanf("%s", &lpData );
  35012.     len = strlen(lpData);
  35013.     
  35014.     // Have to do this before the Padding...well...it's best anyway;)
  35015.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35016.     
  35017.     // For the strings, we're gonna pad and digest the string
  35018.     // in one pass.
  35019.     MDxInit( &mdDataSum );
  35020.     MDxPad( lpData, len, len );
  35021.     
  35022.     MD5Translate( lpData, len, &mdDataSum );
  35023.         // New step necessary because of the 'chunking' method
  35024.         MDxFinalize( &mdDataSum );
  35025.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35026.     
  35027.     MDxInit( &mdDataSum );
  35028.     MD4Translate( lpData, len, &mdDataSum );    
  35029.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35030.  
  35031.     return;
  35032. }
  35033.  
  35034.  
  35035. -------------- Include
  35036.  
  35037. #ifndef __windows_h__
  35038.         typedef unsigned long DWORD;
  35039.         #define STDCALL _stdcall
  35040. #endif
  35041.  
  35042. typedef struct 
  35043. {
  35044.     DWORD dwSum[4];
  35045. }MDxSum;
  35046.  
  35047. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35048. void STDCALL MDxInit( MDxSum * );
  35049. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35050. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35051. const char * STDCALL MDxGetVersion();
  35052. void STDCALL MDxFinalize( MDxSum * );
  35053.  
  35054.  
  35055.  
  35056. #include "mdx.h"
  35057. #include <stdlib.h>
  35058. #include <stdio.h>
  35059. #include <string.h>
  35060.  
  35061. // READLEN % 64 must = 0
  35062. #define READLEN    1048576L // 2^20, 1MB
  35063.  
  35064. void DigestFile( char * );
  35065. void DigestString();
  35066.  
  35067. void main(int argc, char *argv[])
  35068. {
  35069.     printf("%s\n\n", MDxGetVersion());
  35070.  
  35071.     if( argc > 1 )
  35072.         DigestFile( argv[1] );
  35073.     else    
  35074.         DigestString();
  35075.  
  35076. }
  35077.  
  35078. /*
  35079.     I use the 'chunk' method for processing files not because of
  35080.     limitations of my dll, but think what would happen if you
  35081.     tried to load an entire cd image into memory.
  35082. */
  35083. void DigestFile( char *szFName )
  35084. {
  35085.     FILE *file;
  35086.     void *lpData;
  35087.     long flen, mlen;
  35088.     MDxSum mdDataSum;
  35089.     MDxSum md4DataSum;
  35090.  
  35091.     // the 64 is for padding purposes
  35092.     lpData = malloc( READLEN + 64 );
  35093.     
  35094.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  35095.  
  35096.     file = fopen( szFName, "rb" );
  35097.     if( file == NULL )
  35098.     {
  35099.         printf("ERROR: File not found.\n");
  35100.         return;
  35101.     }
  35102.     
  35103.     MDxInit( &mdDataSum );
  35104.     MDxInit( &md4DataSum );
  35105.     
  35106.     fseek( file, 0, SEEK_END );
  35107.     //Get the file length
  35108.     flen = mlen = ftell( file );
  35109.     fseek( file, 0, SEEK_SET );
  35110.     
  35111.     // When it takes a while to process a large file,
  35112.     // remember that for each chunk it has to run 
  35113.     // through the main translation loop 16384 times!
  35114.         
  35115.     printf("Processing %ld byte file: .", flen );
  35116.     
  35117.     while( flen > READLEN )
  35118.     {
  35119.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  35120.         {
  35121.             printf("READ ERROR!\n");
  35122.             return;
  35123.         }
  35124.         MD5Translate( lpData, READLEN, &mdDataSum );
  35125.         MD4Translate( lpData, READLEN, &md4DataSum );
  35126.         flen -= READLEN;
  35127.         printf(".");
  35128.     }
  35129.  
  35130.     if (fread( lpData, 1, flen, file ) != flen)
  35131.     {
  35132.         printf("READ ERROR!\n");
  35133.         return;
  35134.     }
  35135.     // This is why I added the new argument to MDxPad
  35136.     // So we can pass the length of the data AND the
  35137.     // Total length of the message
  35138.     // Also it now returns the # of padding bytes added,
  35139.     // this is for files that are an exact multiple of the chunk
  35140.     // length. (Otherwise the padding isn't Translated)
  35141.     flen += MDxPad( lpData, flen, mlen );
  35142.     MD5Translate( lpData, flen, &mdDataSum );    
  35143.     MD4Translate( lpData, flen, &md4DataSum );
  35144.  
  35145.     // New step necessary because of the 'chunking' method
  35146.     MDxFinalize( &mdDataSum );
  35147.     MDxFinalize( &md4DataSum );
  35148.     
  35149.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  35150.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35151.     fclose(file);
  35152.         
  35153. }
  35154.  
  35155. void DigestString()
  35156. {
  35157.     
  35158.     //For our demo purposes, no strings bigger than 1024 :)
  35159.     unsigned char lpData[1024] = "";
  35160.     long len = 0;
  35161.     MDxSum mdDataSum;
  35162.  
  35163.     printf("Enter the string to digest: ");
  35164.     scanf("%s", &lpData );
  35165.     len = strlen(lpData);
  35166.     
  35167.     // Have to do this before the Padding...well...it's best anyway;)
  35168.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35169.     
  35170.     // For the strings, we're gonna pad and digest the string
  35171.     // in one pass.
  35172.     MDxInit( &mdDataSum );
  35173.     MDxPad( lpData, len, len );
  35174.     
  35175.     MD5Translate( lpData, len, &mdDataSum );
  35176.         // New step necessary because of the 'chunking' method
  35177.         MDxFinalize( &mdDataSum );
  35178.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35179.     
  35180.     MDxInit( &mdDataSum );
  35181.     MD4Translate( lpData, len, &mdDataSum );    
  35182.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35183.  
  35184.     return;
  35185. }
  35186.  
  35187.  
  35188. -------------- Include
  35189.  
  35190. #ifndef __windows_h__
  35191.         typedef unsigned long DWORD;
  35192.         #define STDCALL _stdcall
  35193. #endif
  35194.  
  35195. typedef struct 
  35196. {
  35197.     DWORD dwSum[4];
  35198. }MDxSum;
  35199.  
  35200. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35201. void STDCALL MDxInit( MDxSum * );
  35202. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35203. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35204. const char * STDCALL MDxGetVersion();
  35205. void STDCALL MDxFinalize( MDxSum * );
  35206.  
  35207.  
  35208.  
  35209. #include "mdx.h"
  35210. #include <stdlib.h>
  35211. #include <stdio.h>
  35212. #include <string.h>
  35213.  
  35214. // READLEN % 64 must = 0
  35215. #define READLEN    1048576L // 2^20, 1MB
  35216.  
  35217. void DigestFile( char * );
  35218. void DigestString();
  35219.  
  35220. void main(int argc, char *argv[])
  35221. {
  35222.     printf("%s\n\n", MDxGetVersion());
  35223.  
  35224.     if( argc > 1 )
  35225.         DigestFile( argv[1] );
  35226.     else    
  35227.         DigestString();
  35228.  
  35229. }
  35230.  
  35231. /*
  35232.     I use the 'chunk' method for processing files not because of
  35233.     limitations of my dll, but think what would happen if you
  35234.     tried to load an entire cd image into memory.
  35235. */
  35236. void DigestFile( char *szFName )
  35237. {
  35238.     FILE *file;
  35239.     void *lpData;
  35240.     long flen, mlen;
  35241.     MDxSum mdDataSum;
  35242.     MDxSum md4DataSum;
  35243.  
  35244.     // the 64 is for padding purposes
  35245.     lpData = malloc( READLEN + 64 );
  35246.     
  35247.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  35248.  
  35249.     file = fopen( szFName, "rb" );
  35250.     if( file == NULL )
  35251.     {
  35252.         printf("ERROR: File not found.\n");
  35253.         return;
  35254.     }
  35255.     
  35256.     MDxInit( &mdDataSum );
  35257.     MDxInit( &md4DataSum );
  35258.     
  35259.     fseek( file, 0, SEEK_END );
  35260.     //Get the file length
  35261.     flen = mlen = ftell( file );
  35262.     fseek( file, 0, SEEK_SET );
  35263.     
  35264.     // When it takes a while to process a large file,
  35265.     // remember that for each chunk it has to run 
  35266.     // through the main translation loop 16384 times!
  35267.         
  35268.     printf("Processing %ld byte file: .", flen );
  35269.     
  35270.     while( flen > READLEN )
  35271.     {
  35272.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  35273.         {
  35274.             printf("READ ERROR!\n");
  35275.             return;
  35276.         }
  35277.         MD5Translate( lpData, READLEN, &mdDataSum );
  35278.         MD4Translate( lpData, READLEN, &md4DataSum );
  35279.         flen -= READLEN;
  35280.         printf(".");
  35281.     }
  35282.  
  35283.     if (fread( lpData, 1, flen, file ) != flen)
  35284.     {
  35285.         printf("READ ERROR!\n");
  35286.         return;
  35287.     }
  35288.     // This is why I added the new argument to MDxPad
  35289.     // So we can pass the length of the data AND the
  35290.     // Total length of the message
  35291.     // Also it now returns the # of padding bytes added,
  35292.     // this is for files that are an exact multiple of the chunk
  35293.     // length. (Otherwise the padding isn't Translated)
  35294.     flen += MDxPad( lpData, flen, mlen );
  35295.     MD5Translate( lpData, flen, &mdDataSum );    
  35296.     MD4Translate( lpData, flen, &md4DataSum );
  35297.  
  35298.     // New step necessary because of the 'chunking' method
  35299.     MDxFinalize( &mdDataSum );
  35300.     MDxFinalize( &md4DataSum );
  35301.     
  35302.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  35303.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35304.     fclose(file);
  35305.         
  35306. }
  35307.  
  35308. void DigestString()
  35309. {
  35310.     
  35311.     //For our demo purposes, no strings bigger than 1024 :)
  35312.     unsigned char lpData[1024] = "";
  35313.     long len = 0;
  35314.     MDxSum mdDataSum;
  35315.  
  35316.     printf("Enter the string to digest: ");
  35317.     scanf("%s", &lpData );
  35318.     len = strlen(lpData);
  35319.     
  35320.     // Have to do this before the Padding...well...it's best anyway;)
  35321.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35322.     
  35323.     // For the strings, we're gonna pad and digest the string
  35324.     // in one pass.
  35325.     MDxInit( &mdDataSum );
  35326.     MDxPad( lpData, len, len );
  35327.     
  35328.     MD5Translate( lpData, len, &mdDataSum );
  35329.         // New step necessary because of the 'chunking' method
  35330.         MDxFinalize( &mdDataSum );
  35331.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35332.     
  35333.     MDxInit( &mdDataSum );
  35334.     MD4Translate( lpData, len, &mdDataSum );    
  35335.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35336.  
  35337.     return;
  35338. }
  35339.  
  35340.  
  35341. -------------- Include
  35342.  
  35343. #ifndef __windows_h__
  35344.         typedef unsigned long DWORD;
  35345.         #define STDCALL _stdcall
  35346. #endif
  35347.  
  35348. typedef struct 
  35349. {
  35350.     DWORD dwSum[4];
  35351. }MDxSum;
  35352.  
  35353. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35354. void STDCALL MDxInit( MDxSum * );
  35355. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35356. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35357. const char * STDCALL MDxGetVersion();
  35358. void STDCALL MDxFinalize( MDxSum * );
  35359.  
  35360.  
  35361.  
  35362. #include "mdx.h"
  35363. #include <stdlib.h>
  35364. #include <stdio.h>
  35365. #include <string.h>
  35366.  
  35367. // READLEN % 64 must = 0
  35368. #define READLEN    1048576L // 2^20, 1MB
  35369.  
  35370. void DigestFile( char * );
  35371. void DigestString();
  35372.  
  35373. void main(int argc, char *argv[])
  35374. {
  35375.     printf("%s\n\n", MDxGetVersion());
  35376.  
  35377.     if( argc > 1 )
  35378.         DigestFile( argv[1] );
  35379.     else    
  35380.         DigestString();
  35381.  
  35382. }
  35383.  
  35384. /*
  35385.     I use the 'chunk' method for processing files not because of
  35386.     limitations of my dll, but think what would happen if you
  35387.     tried to load an entire cd image into memory.
  35388. */
  35389. void DigestFile( char *szFName )
  35390. {
  35391.     FILE *file;
  35392.     void *lpData;
  35393.     long flen, mlen;
  35394.     MDxSum mdDataSum;
  35395.     MDxSum md4DataSum;
  35396.  
  35397.     // the 64 is for padding purposes
  35398.     lpData = malloc( READLEN + 64 );
  35399.     
  35400.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  35401.  
  35402.     file = fopen( szFName, "rb" );
  35403.     if( file == NULL )
  35404.     {
  35405.         printf("ERROR: File not found.\n");
  35406.         return;
  35407.     }
  35408.     
  35409.     MDxInit( &mdDataSum );
  35410.     MDxInit( &md4DataSum );
  35411.     
  35412.     fseek( file, 0, SEEK_END );
  35413.     //Get the file length
  35414.     flen = mlen = ftell( file );
  35415.     fseek( file, 0, SEEK_SET );
  35416.     
  35417.     // When it takes a while to process a large file,
  35418.     // remember that for each chunk it has to run 
  35419.     // through the main translation loop 16384 times!
  35420.         
  35421.     printf("Processing %ld byte file: .", flen );
  35422.     
  35423.     while( flen > READLEN )
  35424.     {
  35425.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  35426.         {
  35427.             printf("READ ERROR!\n");
  35428.             return;
  35429.         }
  35430.         MD5Translate( lpData, READLEN, &mdDataSum );
  35431.         MD4Translate( lpData, READLEN, &md4DataSum );
  35432.         flen -= READLEN;
  35433.         printf(".");
  35434.     }
  35435.  
  35436.     if (fread( lpData, 1, flen, file ) != flen)
  35437.     {
  35438.         printf("READ ERROR!\n");
  35439.         return;
  35440.     }
  35441.     // This is why I added the new argument to MDxPad
  35442.     // So we can pass the length of the data AND the
  35443.     // Total length of the message
  35444.     // Also it now returns the # of padding bytes added,
  35445.     // this is for files that are an exact multiple of the chunk
  35446.     // length. (Otherwise the padding isn't Translated)
  35447.     flen += MDxPad( lpData, flen, mlen );
  35448.     MD5Translate( lpData, flen, &mdDataSum );    
  35449.     MD4Translate( lpData, flen, &md4DataSum );
  35450.  
  35451.     // New step necessary because of the 'chunking' method
  35452.     MDxFinalize( &mdDataSum );
  35453.     MDxFinalize( &md4DataSum );
  35454.     
  35455.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  35456.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35457.     fclose(file);
  35458.         
  35459. }
  35460.  
  35461. void DigestString()
  35462. {
  35463.     
  35464.     //For our demo purposes, no strings bigger than 1024 :)
  35465.     unsigned char lpData[1024] = "";
  35466.     long len = 0;
  35467.     MDxSum mdDataSum;
  35468.  
  35469.     printf("Enter the string to digest: ");
  35470.     scanf("%s", &lpData );
  35471.     len = strlen(lpData);
  35472.     
  35473.     // Have to do this before the Padding...well...it's best anyway;)
  35474.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35475.     
  35476.     // For the strings, we're gonna pad and digest the string
  35477.     // in one pass.
  35478.     MDxInit( &mdDataSum );
  35479.     MDxPad( lpData, len, len );
  35480.     
  35481.     MD5Translate( lpData, len, &mdDataSum );
  35482.         // New step necessary because of the 'chunking' method
  35483.         MDxFinalize( &mdDataSum );
  35484.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35485.     
  35486.     MDxInit( &mdDataSum );
  35487.     MD4Translate( lpData, len, &mdDataSum );    
  35488.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35489.  
  35490.     return;
  35491. }
  35492.  
  35493.  
  35494. -------------- Include
  35495.  
  35496. #ifndef __windows_h__
  35497.         typedef unsigned long DWORD;
  35498.         #define STDCALL _stdcall
  35499. #endif
  35500.  
  35501. typedef struct 
  35502. {
  35503.     DWORD dwSum[4];
  35504. }MDxSum;
  35505.  
  35506. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35507. void STDCALL MDxInit( MDxSum * );
  35508. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35509. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35510. const char * STDCALL MDxGetVersion();
  35511. void STDCALL MDxFinalize( MDxSum * );
  35512.  
  35513.  
  35514.  
  35515. #include "mdx.h"
  35516. #include <stdlib.h>
  35517. #include <stdio.h>
  35518. #include <string.h>
  35519.  
  35520. // READLEN % 64 must = 0
  35521. #define READLEN    1048576L // 2^20, 1MB
  35522.  
  35523. void DigestFile( char * );
  35524. void DigestString();
  35525.  
  35526. void main(int argc, char *argv[])
  35527. {
  35528.     printf("%s\n\n", MDxGetVersion());
  35529.  
  35530.     if( argc > 1 )
  35531.         DigestFile( argv[1] );
  35532.     else    
  35533.         DigestString();
  35534.  
  35535. }
  35536.  
  35537. /*
  35538.     I use the 'chunk' method for processing files not because of
  35539.     limitations of my dll, but think what would happen if you
  35540.     tried to load an entire cd image into memory.
  35541. */
  35542. void DigestFile( char *szFName )
  35543. {
  35544.     FILE *file;
  35545.     void *lpData;
  35546.     long flen, mlen;
  35547.     MDxSum mdDataSum;
  35548.     MDxSum md4DataSum;
  35549.  
  35550.     // the 64 is for padding purposes
  35551.     lpData = malloc( READLEN + 64 );
  35552.     
  35553.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  35554.  
  35555.     file = fopen( szFName, "rb" );
  35556.     if( file == NULL )
  35557.     {
  35558.         printf("ERROR: File not found.\n");
  35559.         return;
  35560.     }
  35561.     
  35562.     MDxInit( &mdDataSum );
  35563.     MDxInit( &md4DataSum );
  35564.     
  35565.     fseek( file, 0, SEEK_END );
  35566.     //Get the file length
  35567.     flen = mlen = ftell( file );
  35568.     fseek( file, 0, SEEK_SET );
  35569.     
  35570.     // When it takes a while to process a large file,
  35571.     // remember that for each chunk it has to run 
  35572.     // through the main translation loop 16384 times!
  35573.         
  35574.     printf("Processing %ld byte file: .", flen );
  35575.     
  35576.     while( flen > READLEN )
  35577.     {
  35578.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  35579.         {
  35580.             printf("READ ERROR!\n");
  35581.             return;
  35582.         }
  35583.         MD5Translate( lpData, READLEN, &mdDataSum );
  35584.         MD4Translate( lpData, READLEN, &md4DataSum );
  35585.         flen -= READLEN;
  35586.         printf(".");
  35587.     }
  35588.  
  35589.     if (fread( lpData, 1, flen, file ) != flen)
  35590.     {
  35591.         printf("READ ERROR!\n");
  35592.         return;
  35593.     }
  35594.     // This is why I added the new argument to MDxPad
  35595.     // So we can pass the length of the data AND the
  35596.     // Total length of the message
  35597.     // Also it now returns the # of padding bytes added,
  35598.     // this is for files that are an exact multiple of the chunk
  35599.     // length. (Otherwise the padding isn't Translated)
  35600.     flen += MDxPad( lpData, flen, mlen );
  35601.     MD5Translate( lpData, flen, &mdDataSum );    
  35602.     MD4Translate( lpData, flen, &md4DataSum );
  35603.  
  35604.     // New step necessary because of the 'chunking' method
  35605.     MDxFinalize( &mdDataSum );
  35606.     MDxFinalize( &md4DataSum );
  35607.     
  35608.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  35609.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35610.     fclose(file);
  35611.         
  35612. }
  35613.  
  35614. void DigestString()
  35615. {
  35616.     
  35617.     //For our demo purposes, no strings bigger than 1024 :)
  35618.     unsigned char lpData[1024] = "";
  35619.     long len = 0;
  35620.     MDxSum mdDataSum;
  35621.  
  35622.     printf("Enter the string to digest: ");
  35623.     scanf("%s", &lpData );
  35624.     len = strlen(lpData);
  35625.     
  35626.     // Have to do this before the Padding...well...it's best anyway;)
  35627.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35628.     
  35629.     // For the strings, we're gonna pad and digest the string
  35630.     // in one pass.
  35631.     MDxInit( &mdDataSum );
  35632.     MDxPad( lpData, len, len );
  35633.     
  35634.     MD5Translate( lpData, len, &mdDataSum );
  35635.         // New step necessary because of the 'chunking' method
  35636.         MDxFinalize( &mdDataSum );
  35637.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35638.     
  35639.     MDxInit( &mdDataSum );
  35640.     MD4Translate( lpData, len, &mdDataSum );    
  35641.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35642.  
  35643.     return;
  35644. }
  35645.  
  35646.  
  35647. -------------- Include
  35648.  
  35649. #ifndef __windows_h__
  35650.         typedef unsigned long DWORD;
  35651.         #define STDCALL _stdcall
  35652. #endif
  35653.  
  35654. typedef struct 
  35655. {
  35656.     DWORD dwSum[4];
  35657. }MDxSum;
  35658.  
  35659. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35660. void STDCALL MDxInit( MDxSum * );
  35661. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35662. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35663. const char * STDCALL MDxGetVersion();
  35664. void STDCALL MDxFinalize( MDxSum * );
  35665.  
  35666.  
  35667.  
  35668. #include "mdx.h"
  35669. #include <stdlib.h>
  35670. #include <stdio.h>
  35671. #include <string.h>
  35672.  
  35673. // READLEN % 64 must = 0
  35674. #define READLEN    1048576L // 2^20, 1MB
  35675.  
  35676. void DigestFile( char * );
  35677. void DigestString();
  35678.  
  35679. void main(int argc, char *argv[])
  35680. {
  35681.     printf("%s\n\n", MDxGetVersion());
  35682.  
  35683.     if( argc > 1 )
  35684.         DigestFile( argv[1] );
  35685.     else    
  35686.         DigestString();
  35687.  
  35688. }
  35689.  
  35690. /*
  35691.     I use the 'chunk' method for processing files not because of
  35692.     limitations of my dll, but think what would happen if you
  35693.     tried to load an entire cd image into memory.
  35694. */
  35695. void DigestFile( char *szFName )
  35696. {
  35697.     FILE *file;
  35698.     void *lpData;
  35699.     long flen, mlen;
  35700.     MDxSum mdDataSum;
  35701.     MDxSum md4DataSum;
  35702.  
  35703.     // the 64 is for padding purposes
  35704.     lpData = malloc( READLEN + 64 );
  35705.     
  35706.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  35707.  
  35708.     file = fopen( szFName, "rb" );
  35709.     if( file == NULL )
  35710.     {
  35711.         printf("ERROR: File not found.\n");
  35712.         return;
  35713.     }
  35714.     
  35715.     MDxInit( &mdDataSum );
  35716.     MDxInit( &md4DataSum );
  35717.     
  35718.     fseek( file, 0, SEEK_END );
  35719.     //Get the file length
  35720.     flen = mlen = ftell( file );
  35721.     fseek( file, 0, SEEK_SET );
  35722.     
  35723.     // When it takes a while to process a large file,
  35724.     // remember that for each chunk it has to run 
  35725.     // through the main translation loop 16384 times!
  35726.         
  35727.     printf("Processing %ld byte file: .", flen );
  35728.     
  35729.     while( flen > READLEN )
  35730.     {
  35731.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  35732.         {
  35733.             printf("READ ERROR!\n");
  35734.             return;
  35735.         }
  35736.         MD5Translate( lpData, READLEN, &mdDataSum );
  35737.         MD4Translate( lpData, READLEN, &md4DataSum );
  35738.         flen -= READLEN;
  35739.         printf(".");
  35740.     }
  35741.  
  35742.     if (fread( lpData, 1, flen, file ) != flen)
  35743.     {
  35744.         printf("READ ERROR!\n");
  35745.         return;
  35746.     }
  35747.     // This is why I added the new argument to MDxPad
  35748.     // So we can pass the length of the data AND the
  35749.     // Total length of the message
  35750.     // Also it now returns the # of padding bytes added,
  35751.     // this is for files that are an exact multiple of the chunk
  35752.     // length. (Otherwise the padding isn't Translated)
  35753.     flen += MDxPad( lpData, flen, mlen );
  35754.     MD5Translate( lpData, flen, &mdDataSum );    
  35755.     MD4Translate( lpData, flen, &md4DataSum );
  35756.  
  35757.     // New step necessary because of the 'chunking' method
  35758.     MDxFinalize( &mdDataSum );
  35759.     MDxFinalize( &md4DataSum );
  35760.     
  35761.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  35762.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35763.     fclose(file);
  35764.         
  35765. }
  35766.  
  35767. void DigestString()
  35768. {
  35769.     
  35770.     //For our demo purposes, no strings bigger than 1024 :)
  35771.     unsigned char lpData[1024] = "";
  35772.     long len = 0;
  35773.     MDxSum mdDataSum;
  35774.  
  35775.     printf("Enter the string to digest: ");
  35776.     scanf("%s", &lpData );
  35777.     len = strlen(lpData);
  35778.     
  35779.     // Have to do this before the Padding...well...it's best anyway;)
  35780.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35781.     
  35782.     // For the strings, we're gonna pad and digest the string
  35783.     // in one pass.
  35784.     MDxInit( &mdDataSum );
  35785.     MDxPad( lpData, len, len );
  35786.     
  35787.     MD5Translate( lpData, len, &mdDataSum );
  35788.         // New step necessary because of the 'chunking' method
  35789.         MDxFinalize( &mdDataSum );
  35790.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35791.     
  35792.     MDxInit( &mdDataSum );
  35793.     MD4Translate( lpData, len, &mdDataSum );    
  35794.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35795.  
  35796.     return;
  35797. }
  35798.  
  35799.  
  35800. -------------- Include
  35801.  
  35802. #ifndef __windows_h__
  35803.         typedef unsigned long DWORD;
  35804.         #define STDCALL _stdcall
  35805. #endif
  35806.  
  35807. typedef struct 
  35808. {
  35809.     DWORD dwSum[4];
  35810. }MDxSum;
  35811.  
  35812. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35813. void STDCALL MDxInit( MDxSum * );
  35814. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35815. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35816. const char * STDCALL MDxGetVersion();
  35817. void STDCALL MDxFinalize( MDxSum * );
  35818.  
  35819.  
  35820.  
  35821. #include "mdx.h"
  35822. #include <stdlib.h>
  35823. #include <stdio.h>
  35824. #include <string.h>
  35825.  
  35826. // READLEN % 64 must = 0
  35827. #define READLEN    1048576L // 2^20, 1MB
  35828.  
  35829. void DigestFile( char * );
  35830. void DigestString();
  35831.  
  35832. void main(int argc, char *argv[])
  35833. {
  35834.     printf("%s\n\n", MDxGetVersion());
  35835.  
  35836.     if( argc > 1 )
  35837.         DigestFile( argv[1] );
  35838.     else    
  35839.         DigestString();
  35840.  
  35841. }
  35842.  
  35843. /*
  35844.     I use the 'chunk' method for processing files not because of
  35845.     limitations of my dll, but think what would happen if you
  35846.     tried to load an entire cd image into memory.
  35847. */
  35848. void DigestFile( char *szFName )
  35849. {
  35850.     FILE *file;
  35851.     void *lpData;
  35852.     long flen, mlen;
  35853.     MDxSum mdDataSum;
  35854.     MDxSum md4DataSum;
  35855.  
  35856.     // the 64 is for padding purposes
  35857.     lpData = malloc( READLEN + 64 );
  35858.     
  35859.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  35860.  
  35861.     file = fopen( szFName, "rb" );
  35862.     if( file == NULL )
  35863.     {
  35864.         printf("ERROR: File not found.\n");
  35865.         return;
  35866.     }
  35867.     
  35868.     MDxInit( &mdDataSum );
  35869.     MDxInit( &md4DataSum );
  35870.     
  35871.     fseek( file, 0, SEEK_END );
  35872.     //Get the file length
  35873.     flen = mlen = ftell( file );
  35874.     fseek( file, 0, SEEK_SET );
  35875.     
  35876.     // When it takes a while to process a large file,
  35877.     // remember that for each chunk it has to run 
  35878.     // through the main translation loop 16384 times!
  35879.         
  35880.     printf("Processing %ld byte file: .", flen );
  35881.     
  35882.     while( flen > READLEN )
  35883.     {
  35884.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  35885.         {
  35886.             printf("READ ERROR!\n");
  35887.             return;
  35888.         }
  35889.         MD5Translate( lpData, READLEN, &mdDataSum );
  35890.         MD4Translate( lpData, READLEN, &md4DataSum );
  35891.         flen -= READLEN;
  35892.         printf(".");
  35893.     }
  35894.  
  35895.     if (fread( lpData, 1, flen, file ) != flen)
  35896.     {
  35897.         printf("READ ERROR!\n");
  35898.         return;
  35899.     }
  35900.     // This is why I added the new argument to MDxPad
  35901.     // So we can pass the length of the data AND the
  35902.     // Total length of the message
  35903.     // Also it now returns the # of padding bytes added,
  35904.     // this is for files that are an exact multiple of the chunk
  35905.     // length. (Otherwise the padding isn't Translated)
  35906.     flen += MDxPad( lpData, flen, mlen );
  35907.     MD5Translate( lpData, flen, &mdDataSum );    
  35908.     MD4Translate( lpData, flen, &md4DataSum );
  35909.  
  35910.     // New step necessary because of the 'chunking' method
  35911.     MDxFinalize( &mdDataSum );
  35912.     MDxFinalize( &md4DataSum );
  35913.     
  35914.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  35915.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35916.     fclose(file);
  35917.         
  35918. }
  35919.  
  35920. void DigestString()
  35921. {
  35922.     
  35923.     //For our demo purposes, no strings bigger than 1024 :)
  35924.     unsigned char lpData[1024] = "";
  35925.     long len = 0;
  35926.     MDxSum mdDataSum;
  35927.  
  35928.     printf("Enter the string to digest: ");
  35929.     scanf("%s", &lpData );
  35930.     len = strlen(lpData);
  35931.     
  35932.     // Have to do this before the Padding...well...it's best anyway;)
  35933.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  35934.     
  35935.     // For the strings, we're gonna pad and digest the string
  35936.     // in one pass.
  35937.     MDxInit( &mdDataSum );
  35938.     MDxPad( lpData, len, len );
  35939.     
  35940.     MD5Translate( lpData, len, &mdDataSum );
  35941.         // New step necessary because of the 'chunking' method
  35942.         MDxFinalize( &mdDataSum );
  35943.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35944.     
  35945.     MDxInit( &mdDataSum );
  35946.     MD4Translate( lpData, len, &mdDataSum );    
  35947.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  35948.  
  35949.     return;
  35950. }
  35951.  
  35952.  
  35953. -------------- Include
  35954.  
  35955. #ifndef __windows_h__
  35956.         typedef unsigned long DWORD;
  35957.         #define STDCALL _stdcall
  35958. #endif
  35959.  
  35960. typedef struct 
  35961. {
  35962.     DWORD dwSum[4];
  35963. }MDxSum;
  35964.  
  35965. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  35966. void STDCALL MDxInit( MDxSum * );
  35967. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  35968. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  35969. const char * STDCALL MDxGetVersion();
  35970. void STDCALL MDxFinalize( MDxSum * );
  35971.  
  35972.  
  35973.  
  35974. #include "mdx.h"
  35975. #include <stdlib.h>
  35976. #include <stdio.h>
  35977. #include <string.h>
  35978.  
  35979. // READLEN % 64 must = 0
  35980. #define READLEN    1048576L // 2^20, 1MB
  35981.  
  35982. void DigestFile( char * );
  35983. void DigestString();
  35984.  
  35985. void main(int argc, char *argv[])
  35986. {
  35987.     printf("%s\n\n", MDxGetVersion());
  35988.  
  35989.     if( argc > 1 )
  35990.         DigestFile( argv[1] );
  35991.     else    
  35992.         DigestString();
  35993.  
  35994. }
  35995.  
  35996. /*
  35997.     I use the 'chunk' method for processing files not because of
  35998.     limitations of my dll, but think what would happen if you
  35999.     tried to load an entire cd image into memory.
  36000. */
  36001. void DigestFile( char *szFName )
  36002. {
  36003.     FILE *file;
  36004.     void *lpData;
  36005.     long flen, mlen;
  36006.     MDxSum mdDataSum;
  36007.     MDxSum md4DataSum;
  36008.  
  36009.     // the 64 is for padding purposes
  36010.     lpData = malloc( READLEN + 64 );
  36011.     
  36012.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36013.  
  36014.     file = fopen( szFName, "rb" );
  36015.     if( file == NULL )
  36016.     {
  36017.         printf("ERROR: File not found.\n");
  36018.         return;
  36019.     }
  36020.     
  36021.     MDxInit( &mdDataSum );
  36022.     MDxInit( &md4DataSum );
  36023.     
  36024.     fseek( file, 0, SEEK_END );
  36025.     //Get the file length
  36026.     flen = mlen = ftell( file );
  36027.     fseek( file, 0, SEEK_SET );
  36028.     
  36029.     // When it takes a while to process a large file,
  36030.     // remember that for each chunk it has to run 
  36031.     // through the main translation loop 16384 times!
  36032.         
  36033.     printf("Processing %ld byte file: .", flen );
  36034.     
  36035.     while( flen > READLEN )
  36036.     {
  36037.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36038.         {
  36039.             printf("READ ERROR!\n");
  36040.             return;
  36041.         }
  36042.         MD5Translate( lpData, READLEN, &mdDataSum );
  36043.         MD4Translate( lpData, READLEN, &md4DataSum );
  36044.         flen -= READLEN;
  36045.         printf(".");
  36046.     }
  36047.  
  36048.     if (fread( lpData, 1, flen, file ) != flen)
  36049.     {
  36050.         printf("READ ERROR!\n");
  36051.         return;
  36052.     }
  36053.     // This is why I added the new argument to MDxPad
  36054.     // So we can pass the length of the data AND the
  36055.     // Total length of the message
  36056.     // Also it now returns the # of padding bytes added,
  36057.     // this is for files that are an exact multiple of the chunk
  36058.     // length. (Otherwise the padding isn't Translated)
  36059.     flen += MDxPad( lpData, flen, mlen );
  36060.     MD5Translate( lpData, flen, &mdDataSum );    
  36061.     MD4Translate( lpData, flen, &md4DataSum );
  36062.  
  36063.     // New step necessary because of the 'chunking' method
  36064.     MDxFinalize( &mdDataSum );
  36065.     MDxFinalize( &md4DataSum );
  36066.     
  36067.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36068.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36069.     fclose(file);
  36070.         
  36071. }
  36072.  
  36073. void DigestString()
  36074. {
  36075.     
  36076.     //For our demo purposes, no strings bigger than 1024 :)
  36077.     unsigned char lpData[1024] = "";
  36078.     long len = 0;
  36079.     MDxSum mdDataSum;
  36080.  
  36081.     printf("Enter the string to digest: ");
  36082.     scanf("%s", &lpData );
  36083.     len = strlen(lpData);
  36084.     
  36085.     // Have to do this before the Padding...well...it's best anyway;)
  36086.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  36087.     
  36088.     // For the strings, we're gonna pad and digest the string
  36089.     // in one pass.
  36090.     MDxInit( &mdDataSum );
  36091.     MDxPad( lpData, len, len );
  36092.     
  36093.     MD5Translate( lpData, len, &mdDataSum );
  36094.         // New step necessary because of the 'chunking' method
  36095.         MDxFinalize( &mdDataSum );
  36096.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36097.     
  36098.     MDxInit( &mdDataSum );
  36099.     MD4Translate( lpData, len, &mdDataSum );    
  36100.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36101.  
  36102.     return;
  36103. }
  36104.  
  36105.  
  36106. -------------- Include
  36107.  
  36108. #ifndef __windows_h__
  36109.         typedef unsigned long DWORD;
  36110.         #define STDCALL _stdcall
  36111. #endif
  36112.  
  36113. typedef struct 
  36114. {
  36115.     DWORD dwSum[4];
  36116. }MDxSum;
  36117.  
  36118. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  36119. void STDCALL MDxInit( MDxSum * );
  36120. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  36121. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  36122. const char * STDCALL MDxGetVersion();
  36123. void STDCALL MDxFinalize( MDxSum * );
  36124.  
  36125.  
  36126. #include "mdx.h"
  36127. #include <stdlib.h>
  36128. #include <stdio.h>
  36129. #include <string.h>
  36130.  
  36131. // READLEN % 64 must = 0
  36132. #define READLEN    1048576L // 2^20, 1MB
  36133.  
  36134. void DigestFile( char * );
  36135. void DigestString();
  36136.  
  36137. void main(int argc, char *argv[])
  36138. {
  36139.     printf("%s\n\n", MDxGetVersion());
  36140.  
  36141.     if( argc > 1 )
  36142.         DigestFile( argv[1] );
  36143.     else    
  36144.         DigestString();
  36145.  
  36146. }
  36147.  
  36148. /*
  36149.     I use the 'chunk' method for processing files not because of
  36150.     limitations of my dll, but think what would happen if you
  36151.     tried to load an entire cd image into memory.
  36152. */
  36153. void DigestFile( char *szFName )
  36154. {
  36155.     FILE *file;
  36156.     void *lpData;
  36157.     long flen, mlen;
  36158.     MDxSum mdDataSum;
  36159.     MDxSum md4DataSum;
  36160.  
  36161.     // the 64 is for padding purposes
  36162.     lpData = malloc( READLEN + 64 );
  36163.     
  36164.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36165.  
  36166.     file = fopen( szFName, "rb" );
  36167.     if( file == NULL )
  36168.     {
  36169.         printf("ERROR: File not found.\n");
  36170.         return;
  36171.     }
  36172.     
  36173.     MDxInit( &mdDataSum );
  36174.     MDxInit( &md4DataSum );
  36175.     
  36176.     fseek( file, 0, SEEK_END );
  36177.     //Get the file length
  36178.     flen = mlen = ftell( file );
  36179.     fseek( file, 0, SEEK_SET );
  36180.     
  36181.     // When it takes a while to process a large file,
  36182.     // remember that for each chunk it has to run 
  36183.     // through the main translation loop 16384 times!
  36184.         
  36185.     printf("Processing %ld byte file: .", flen );
  36186.     
  36187.     while( flen > READLEN )
  36188.     {
  36189.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36190.         {
  36191.             printf("READ ERROR!\n");
  36192.             return;
  36193.         }
  36194.         MD5Translate( lpData, READLEN, &mdDataSum );
  36195.         MD4Translate( lpData, READLEN, &md4DataSum );
  36196.         flen -= READLEN;
  36197.         printf(".");
  36198.     }
  36199.  
  36200.     if (fread( lpData, 1, flen, file ) != flen)
  36201.     {
  36202.         printf("READ ERROR!\n");
  36203.         return;
  36204.     }
  36205.     // This is why I added the new argument to MDxPad
  36206.     // So we can pass the length of the data AND the
  36207.     // Total length of the message
  36208.     // Also it now returns the # of padding bytes added,
  36209.     // this is for files that are an exact multiple of the chunk
  36210.     // length. (Otherwise the padding isn't Translated)
  36211.     flen += MDxPad( lpData, flen, mlen );
  36212.     MD5Translate( lpData, flen, &mdDataSum );    
  36213.     MD4Translate( lpData, flen, &md4DataSum );
  36214.  
  36215.     // New step necessary because of the 'chunking' method
  36216.     MDxFinalize( &mdDataSum );
  36217.     MDxFinalize( &md4DataSum );
  36218.     
  36219.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36220.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36221.     fclose(file);
  36222.         
  36223. }
  36224.  
  36225. void DigestString()
  36226. {
  36227.     
  36228.     //For our demo purposes, no strings bigger than 1024 :)
  36229.     unsigned char lpData[1024] = "";
  36230.     long len = 0;
  36231.     MDxSum mdDataSum;
  36232.  
  36233.     printf("Enter the string to digest: ");
  36234.     scanf("%s", &lpData );
  36235.     len = strlen(lpData);
  36236.     
  36237.     // Have to do this before the Padding...well...it's best anyway;)
  36238.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  36239.     
  36240.     // For the strings, we're gonna pad and digest the string
  36241.     // in one pass.
  36242.     MDxInit( &mdDataSum );
  36243.     MDxPad( lpData, len, len );
  36244.     
  36245.     MD5Translate( lpData, len, &mdDataSum );
  36246.         // New step necessary because of the 'chunking' method
  36247.         MDxFinalize( &mdDataSum );
  36248.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36249.     
  36250.     MDxInit( &mdDataSum );
  36251.     MD4Translate( lpData, len, &mdDataSum );    
  36252.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36253.  
  36254.     return;
  36255. }
  36256.  
  36257.  
  36258. -------------- Include
  36259.  
  36260. #ifndef __windows_h__
  36261.         typedef unsigned long DWORD;
  36262.         #define STDCALL _stdcall
  36263. #endif
  36264.  
  36265. typedef struct 
  36266. {
  36267.     DWORD dwSum[4];
  36268. }MDxSum;
  36269.  
  36270. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  36271. void STDCALL MDxInit( MDxSum * );
  36272. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  36273. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  36274. const char * STDCALL MDxGetVersion();
  36275. void STDCALL MDxFinalize( MDxSum * );
  36276.  
  36277.  
  36278. #include "mdx.h"
  36279. #include <stdlib.h>
  36280. #include <stdio.h>
  36281. #include <string.h>
  36282.  
  36283. // READLEN % 64 must = 0
  36284. #define READLEN    1048576L // 2^20, 1MB
  36285.  
  36286. void DigestFile( char * );
  36287. void DigestString();
  36288.  
  36289. void main(int argc, char *argv[])
  36290. {
  36291.     printf("%s\n\n", MDxGetVersion());
  36292.  
  36293.     if( argc > 1 )
  36294.         DigestFile( argv[1] );
  36295.     else    
  36296.         DigestString();
  36297.  
  36298. }
  36299.  
  36300. /*
  36301.     I use the 'chunk' method for processing files not because of
  36302.     limitations of my dll, but think what would happen if you
  36303.     tried to load an entire cd image into memory.
  36304. */
  36305. void DigestFile( char *szFName )
  36306. {
  36307.     FILE *file;
  36308.     void *lpData;
  36309.     long flen, mlen;
  36310.     MDxSum mdDataSum;
  36311.     MDxSum md4DataSum;
  36312.  
  36313.     // the 64 is for padding purposes
  36314.     lpData = malloc( READLEN + 64 );
  36315.     
  36316.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36317.  
  36318.     file = fopen( szFName, "rb" );
  36319.     if( file == NULL )
  36320.     {
  36321.         printf("ERROR: File not found.\n");
  36322.         return;
  36323.     }
  36324.     
  36325.     MDxInit( &mdDataSum );
  36326.     MDxInit( &md4DataSum );
  36327.     
  36328.     fseek( file, 0, SEEK_END );
  36329.     //Get the file length
  36330.     flen = mlen = ftell( file );
  36331.     fseek( file, 0, SEEK_SET );
  36332.     
  36333.     // When it takes a while to process a large file,
  36334.     // remember that for each chunk it has to run 
  36335.     // through the main translation loop 16384 times!
  36336.         
  36337.     printf("Processing %ld byte file: .", flen );
  36338.     
  36339.     while( flen > READLEN )
  36340.     {
  36341.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36342.         {
  36343.             printf("READ ERROR!\n");
  36344.             return;
  36345.         }
  36346.         MD5Translate( lpData, READLEN, &mdDataSum );
  36347.         MD4Translate( lpData, READLEN, &md4DataSum );
  36348.         flen -= READLEN;
  36349.         printf(".");
  36350.     }
  36351.  
  36352.     if (fread( lpData, 1, flen, file ) != flen)
  36353.     {
  36354.         printf("READ ERROR!\n");
  36355.         return;
  36356.     }
  36357.     // This is why I added the new argument to MDxPad
  36358.     // So we can pass the length of the data AND the
  36359.     // Total length of the message
  36360.     // Also it now returns the # of padding bytes added,
  36361.     // this is for files that are an exact multiple of the chunk
  36362.     // length. (Otherwise the padding isn't Translated)
  36363.     flen += MDxPad( lpData, flen, mlen );
  36364.     MD5Translate( lpData, flen, &mdDataSum );    
  36365.     MD4Translate( lpData, flen, &md4DataSum );
  36366.  
  36367.     // New step necessary because of the 'chunking' method
  36368.     MDxFinalize( &mdDataSum );
  36369.     MDxFinalize( &md4DataSum );
  36370.     
  36371.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36372.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36373.     fclose(file);
  36374.         
  36375. }
  36376.  
  36377. void DigestString()
  36378. {
  36379.     
  36380.     //For our demo purposes, no strings bigger than 1024 :)
  36381.     unsigned char lpData[1024] = "";
  36382.     long len = 0;
  36383.     MDxSum mdDataSum;
  36384.  
  36385.     printf("Enter the string to digest: ");
  36386.     scanf("%s", &lpData );
  36387.     len = strlen(lpData);
  36388.     
  36389.     // Have to do this before the Padding...well...it's best anyway;)
  36390.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  36391.     
  36392.     // For the strings, we're gonna pad and digest the string
  36393.     // in one pass.
  36394.     MDxInit( &mdDataSum );
  36395.     MDxPad( lpData, len, len );
  36396.     
  36397.     MD5Translate( lpData, len, &mdDataSum );
  36398.         // New step necessary because of the 'chunking' method
  36399.         MDxFinalize( &mdDataSum );
  36400.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36401.     
  36402.     MDxInit( &mdDataSum );
  36403.     MD4Translate( lpData, len, &mdDataSum );    
  36404.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36405.  
  36406.     return;
  36407. }
  36408.  
  36409.  
  36410. -------------- Include
  36411.  
  36412. #ifndef __windows_h__
  36413.         typedef unsigned long DWORD;
  36414.         #define STDCALL _stdcall
  36415. #endif
  36416.  
  36417. typedef struct 
  36418. {
  36419.     DWORD dwSum[4];
  36420. }MDxSum;
  36421.  
  36422. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  36423. void STDCALL MDxInit( MDxSum * );
  36424. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  36425. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  36426. const char * STDCALL MDxGetVersion();
  36427. void STDCALL MDxFinalize( MDxSum * );
  36428.  
  36429. #include "mdx.h"
  36430. #include <stdlib.h>
  36431. #include <stdio.h>
  36432. #include <string.h>
  36433.  
  36434. // READLEN % 64 must = 0
  36435. #define READLEN    1048576L // 2^20, 1MB
  36436.  
  36437. void DigestFile( char * );
  36438. void DigestString();
  36439.  
  36440. void main(int argc, char *argv[])
  36441. {
  36442.     printf("%s\n\n", MDxGetVersion());
  36443.  
  36444.     if( argc > 1 )
  36445.         DigestFile( argv[1] );
  36446.     else    
  36447.         DigestString();
  36448.  
  36449. }
  36450.  
  36451. /*
  36452.     I use the 'chunk' method for processing files not because of
  36453.     limitations of my dll, but think what would happen if you
  36454.     tried to load an entire cd image into memory.
  36455. */
  36456. void DigestFile( char *szFName )
  36457. {
  36458.     FILE *file;
  36459.     void *lpData;
  36460.     long flen, mlen;
  36461.     MDxSum mdDataSum;
  36462.     MDxSum md4DataSum;
  36463.  
  36464.     // the 64 is for padding purposes
  36465.     lpData = malloc( READLEN + 64 );
  36466.     
  36467.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36468.  
  36469.     file = fopen( szFName, "rb" );
  36470.     if( file == NULL )
  36471.     {
  36472.         printf("ERROR: File not found.\n");
  36473.         return;
  36474.     }
  36475.     
  36476.     MDxInit( &mdDataSum );
  36477.     MDxInit( &md4DataSum );
  36478.     
  36479.     fseek( file, 0, SEEK_END );
  36480.     //Get the file length
  36481.     flen = mlen = ftell( file );
  36482.     fseek( file, 0, SEEK_SET );
  36483.     
  36484.     // When it takes a while to process a large file,
  36485.     // remember that for each chunk it has to run 
  36486.     // through the main translation loop 16384 times!
  36487.         
  36488.     printf("Processing %ld byte file: .", flen );
  36489.     
  36490.     while( flen > READLEN )
  36491.     {
  36492.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36493.         {
  36494.             printf("READ ERROR!\n");
  36495.             return;
  36496.         }
  36497.         MD5Translate( lpData, READLEN, &mdDataSum );
  36498.         MD4Translate( lpData, READLEN, &md4DataSum );
  36499.         flen -= READLEN;
  36500.         printf(".");
  36501.     }
  36502.  
  36503.     if (fread( lpData, 1, flen, file ) != flen)
  36504.     {
  36505.         printf("READ ERROR!\n");
  36506.         return;
  36507.     }
  36508.     // This is why I added the new argument to MDxPad
  36509.     // So we can pass the length of the data AND the
  36510.     // Total length of the message
  36511.     // Also it now returns the # of padding bytes added,
  36512.     // this is for files that are an exact multiple of the chunk
  36513.     // length. (Otherwise the padding isn't Translated)
  36514.     flen += MDxPad( lpData, flen, mlen );
  36515.     MD5Translate( lpData, flen, &mdDataSum );    
  36516.     MD4Translate( lpData, flen, &md4DataSum );
  36517.  
  36518.     // New step necessary because of the 'chunking' method
  36519.     MDxFinalize( &mdDataSum );
  36520.     MDxFinalize( &md4DataSum );
  36521.     
  36522.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36523.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36524.     fclose(file);
  36525.         
  36526. }
  36527.  
  36528. void DigestString()
  36529. {
  36530.     
  36531.     //For our demo purposes, no strings bigger than 1024 :)
  36532.     unsigned char lpData[1024] = "";
  36533.     long len = 0;
  36534.     MDxSum mdDataSum;
  36535.  
  36536.     printf("Enter the string to digest: ");
  36537.     scanf("%s", &lpData );
  36538.     len = strlen(lpData);
  36539.     
  36540.     // Have to do this before the Padding...well...it's best anyway;)
  36541.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  36542.     
  36543.     // For the strings, we're gonna pad and digest the string
  36544.     // in one pass.
  36545.     MDxInit( &mdDataSum );
  36546.     MDxPad( lpData, len, len );
  36547.     
  36548.     MD5Translate( lpData, len, &mdDataSum );
  36549.         // New step necessary because of the 'chunking' method
  36550.         MDxFinalize( &mdDataSum );
  36551.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36552.     
  36553.     MDxInit( &mdDataSum );
  36554.     MD4Translate( lpData, len, &mdDataSum );    
  36555.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36556.  
  36557.     return;
  36558. }
  36559.  
  36560.  
  36561. -------------- Include
  36562.  
  36563. #ifndef __windows_h__
  36564.         typedef unsigned long DWORD;
  36565.         #define STDCALL _stdcall
  36566. #endif
  36567.  
  36568. typedef struct 
  36569. {
  36570.     DWORD dwSum[4];
  36571. }MDxSum;
  36572.  
  36573. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  36574. void STDCALL MDxInit( MDxSum * );
  36575. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  36576. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  36577. const char * STDCALL MDxGetVersion();
  36578. void STDCALL MDxFinalize( MDxSum * );
  36579.  
  36580.  
  36581.  
  36582. #include "mdx.h"
  36583. #include <stdlib.h>
  36584. #include <stdio.h>
  36585. #include <string.h>
  36586.  
  36587. // READLEN % 64 must = 0
  36588. #define READLEN    1048576L // 2^20, 1MB
  36589.  
  36590. void DigestFile( char * );
  36591. void DigestString();
  36592.  
  36593. void main(int argc, char *argv[])
  36594. {
  36595.     printf("%s\n\n", MDxGetVersion());
  36596.  
  36597.     if( argc > 1 )
  36598.         DigestFile( argv[1] );
  36599.     else    
  36600.         DigestString();
  36601.  
  36602. }
  36603.  
  36604. /*
  36605.     I use the 'chunk' method for processing files not because of
  36606.     limitations of my dll, but think what would happen if you
  36607.     tried to load an entire cd image into memory.
  36608. */
  36609. void DigestFile( char *szFName )
  36610. {
  36611.     FILE *file;
  36612.     void *lpData;
  36613.     long flen, mlen;
  36614.     MDxSum mdDataSum;
  36615.     MDxSum md4DataSum;
  36616.  
  36617.     // the 64 is for padding purposes
  36618.     lpData = malloc( READLEN + 64 );
  36619.     
  36620.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36621.  
  36622.     file = fopen( szFName, "rb" );
  36623.     if( file == NULL )
  36624.     {
  36625.         printf("ERROR: File not found.\n");
  36626.         return;
  36627.     }
  36628.     
  36629.     MDxInit( &mdDataSum );
  36630.     MDxInit( &md4DataSum );
  36631.     
  36632.     fseek( file, 0, SEEK_END );
  36633.     //Get the file length
  36634.     flen = mlen = ftell( file );
  36635.     fseek( file, 0, SEEK_SET );
  36636.     
  36637.     // When it takes a while to process a large file,
  36638.     // remember that for each chunk it has to run 
  36639.     // through the main translation loop 16384 times!
  36640.         
  36641.     printf("Processing %ld byte file: .", flen );
  36642.     
  36643.     while( flen > READLEN )
  36644.     {
  36645.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36646.         {
  36647.             printf("READ ERROR!\n");
  36648.             return;
  36649.         }
  36650.         MD5Translate( lpData, READLEN, &mdDataSum );
  36651.         MD4Translate( lpData, READLEN, &md4DataSum );
  36652.         flen -= READLEN;
  36653.         printf(".");
  36654.     }
  36655.  
  36656.     if (fread( lpData, 1, flen, file ) != flen)
  36657.     {
  36658.         printf("READ ERROR!\n");
  36659.         return;
  36660.     }
  36661.     // This is why I added the new argument to MDxPad
  36662.     // So we can pass the length of the data AND the
  36663.     // Total length of the message
  36664.     // Also it now returns the # of padding bytes added,
  36665.     // this is for files that are an exact multiple of the chunk
  36666.     // length. (Otherwise the padding isn't Translated)
  36667.     flen += MDxPad( lpData, flen, mlen );
  36668.     MD5Translate( lpData, flen, &mdDataSum );    
  36669.     MD4Translate( lpData, flen, &md4DataSum );
  36670.  
  36671.     // New step necessary because of the 'chunking' method
  36672.     MDxFinalize( &mdDataSum );
  36673.     MDxFinalize( &md4DataSum );
  36674.     
  36675.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36676.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36677.     fclose(file);
  36678.         
  36679. }
  36680.  
  36681. void DigestString()
  36682. {
  36683.     
  36684.     //For our demo purposes, no strings bigger than 1024 :)
  36685.     unsigned char lpData[1024] = "";
  36686.     long len = 0;
  36687.     MDxSum mdDataSum;
  36688.  
  36689.     printf("Enter the string to digest: ");
  36690.     scanf("%s", &lpData );
  36691.     len = strlen(lpData);
  36692.     
  36693.     // Have to do this before the Padding...well...it's best anyway;)
  36694.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  36695.     
  36696.     // For the strings, we're gonna pad and digest the string
  36697.     // in one pass.
  36698.     MDxInit( &mdDataSum );
  36699.     MDxPad( lpData, len, len );
  36700.     
  36701.     MD5Translate( lpData, len, &mdDataSum );
  36702.         // New step necessary because of the 'chunking' method
  36703.         MDxFinalize( &mdDataSum );
  36704.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36705.     
  36706.     MDxInit( &mdDataSum );
  36707.     MD4Translate( lpData, len, &mdDataSum );    
  36708.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36709.  
  36710.     return;
  36711. }
  36712.  
  36713.  
  36714. -------------- Include
  36715.  
  36716. #ifndef __windows_h__
  36717.         typedef unsigned long DWORD;
  36718.         #define STDCALL _stdcall
  36719. #endif
  36720.  
  36721. typedef struct 
  36722. {
  36723.     DWORD dwSum[4];
  36724. }MDxSum;
  36725.  
  36726. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  36727. void STDCALL MDxInit( MDxSum * );
  36728. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  36729. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  36730. const char * STDCALL MDxGetVersion();
  36731. void STDCALL MDxFinalize( MDxSum * );
  36732.  
  36733.  
  36734.  
  36735. #include "mdx.h"
  36736. #include <stdlib.h>
  36737. #include <stdio.h>
  36738. #include <string.h>
  36739.  
  36740. // READLEN % 64 must = 0
  36741. #define READLEN    1048576L // 2^20, 1MB
  36742.  
  36743. void DigestFile( char * );
  36744. void DigestString();
  36745.  
  36746. void main(int argc, char *argv[])
  36747. {
  36748.     printf("%s\n\n", MDxGetVersion());
  36749.  
  36750.     if( argc > 1 )
  36751.         DigestFile( argv[1] );
  36752.     else    
  36753.         DigestString();
  36754.  
  36755. }
  36756.  
  36757. /*
  36758.     I use the 'chunk' method for processing files not because of
  36759.     limitations of my dll, but think what would happen if you
  36760.     tried to load an entire cd image into memory.
  36761. */
  36762. void DigestFile( char *szFName )
  36763. {
  36764.     FILE *file;
  36765.     void *lpData;
  36766.     long flen, mlen;
  36767.     MDxSum mdDataSum;
  36768.     MDxSum md4DataSum;
  36769.  
  36770.     // the 64 is for padding purposes
  36771.     lpData = malloc( READLEN + 64 );
  36772.     
  36773.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36774.  
  36775.     file = fopen( szFName, "rb" );
  36776.     if( file == NULL )
  36777.     {
  36778.         printf("ERROR: File not found.\n");
  36779.         return;
  36780.     }
  36781.     
  36782.     MDxInit( &mdDataSum );
  36783.     MDxInit( &md4DataSum );
  36784.     
  36785.     fseek( file, 0, SEEK_END );
  36786.     //Get the file length
  36787.     flen = mlen = ftell( file );
  36788.     fseek( file, 0, SEEK_SET );
  36789.     
  36790.     // When it takes a while to process a large file,
  36791.     // remember that for each chunk it has to run 
  36792.     // through the main translation loop 16384 times!
  36793.         
  36794.     printf("Processing %ld byte file: .", flen );
  36795.     
  36796.     while( flen > READLEN )
  36797.     {
  36798.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36799.         {
  36800.             printf("READ ERROR!\n");
  36801.             return;
  36802.         }
  36803.         MD5Translate( lpData, READLEN, &mdDataSum );
  36804.         MD4Translate( lpData, READLEN, &md4DataSum );
  36805.         flen -= READLEN;
  36806.         printf(".");
  36807.     }
  36808.  
  36809.     if (fread( lpData, 1, flen, file ) != flen)
  36810.     {
  36811.         printf("READ ERROR!\n");
  36812.         return;
  36813.     }
  36814.     // This is why I added the new argument to MDxPad
  36815.     // So we can pass the length of the data AND the
  36816.     // Total length of the message
  36817.     // Also it now returns the # of padding bytes added,
  36818.     // this is for files that are an exact multiple of the chunk
  36819.     // length. (Otherwise the padding isn't Translated)
  36820.     flen += MDxPad( lpData, flen, mlen );
  36821.     MD5Translate( lpData, flen, &mdDataSum );    
  36822.     MD4Translate( lpData, flen, &md4DataSum );
  36823.  
  36824.     // New step necessary because of the 'chunking' method
  36825.     MDxFinalize( &mdDataSum );
  36826.     MDxFinalize( &md4DataSum );
  36827.     
  36828.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36829.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36830.     fclose(file);
  36831.         
  36832. }
  36833.  
  36834. void DigestString()
  36835. {
  36836.     
  36837.     //For our demo purposes, no strings bigger than 1024 :)
  36838.     unsigned char lpData[1024] = "";
  36839.     long len = 0;
  36840.     MDxSum mdDataSum;
  36841.  
  36842.     printf("Enter the string to digest: ");
  36843.     scanf("%s", &lpData );
  36844.     len = strlen(lpData);
  36845.     
  36846.     // Have to do this before the Padding...well...it's best anyway;)
  36847.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  36848.     
  36849.     // For the strings, we're gonna pad and digest the string
  36850.     // in one pass.
  36851.     MDxInit( &mdDataSum );
  36852.     MDxPad( lpData, len, len );
  36853.     
  36854.     MD5Translate( lpData, len, &mdDataSum );
  36855.         // New step necessary because of the 'chunking' method
  36856.         MDxFinalize( &mdDataSum );
  36857.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36858.     
  36859.     MDxInit( &mdDataSum );
  36860.     MD4Translate( lpData, len, &mdDataSum );    
  36861.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36862.  
  36863.     return;
  36864. }
  36865.  
  36866.  
  36867. -------------- Include
  36868.  
  36869. #ifndef __windows_h__
  36870.         typedef unsigned long DWORD;
  36871.         #define STDCALL _stdcall
  36872. #endif
  36873.  
  36874. typedef struct 
  36875. {
  36876.     DWORD dwSum[4];
  36877. }MDxSum;
  36878.  
  36879. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  36880. void STDCALL MDxInit( MDxSum * );
  36881. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  36882. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  36883. const char * STDCALL MDxGetVersion();
  36884. void STDCALL MDxFinalize( MDxSum * );
  36885.  
  36886.  
  36887.  
  36888. #include "mdx.h"
  36889. #include <stdlib.h>
  36890. #include <stdio.h>
  36891. #include <string.h>
  36892.  
  36893. // READLEN % 64 must = 0
  36894. #define READLEN    1048576L // 2^20, 1MB
  36895.  
  36896. void DigestFile( char * );
  36897. void DigestString();
  36898.  
  36899. void main(int argc, char *argv[])
  36900. {
  36901.     printf("%s\n\n", MDxGetVersion());
  36902.  
  36903.     if( argc > 1 )
  36904.         DigestFile( argv[1] );
  36905.     else    
  36906.         DigestString();
  36907.  
  36908. }
  36909.  
  36910. /*
  36911.     I use the 'chunk' method for processing files not because of
  36912.     limitations of my dll, but think what would happen if you
  36913.     tried to load an entire cd image into memory.
  36914. */
  36915. void DigestFile( char *szFName )
  36916. {
  36917.     FILE *file;
  36918.     void *lpData;
  36919.     long flen, mlen;
  36920.     MDxSum mdDataSum;
  36921.     MDxSum md4DataSum;
  36922.  
  36923.     // the 64 is for padding purposes
  36924.     lpData = malloc( READLEN + 64 );
  36925.     
  36926.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  36927.  
  36928.     file = fopen( szFName, "rb" );
  36929.     if( file == NULL )
  36930.     {
  36931.         printf("ERROR: File not found.\n");
  36932.         return;
  36933.     }
  36934.     
  36935.     MDxInit( &mdDataSum );
  36936.     MDxInit( &md4DataSum );
  36937.     
  36938.     fseek( file, 0, SEEK_END );
  36939.     //Get the file length
  36940.     flen = mlen = ftell( file );
  36941.     fseek( file, 0, SEEK_SET );
  36942.     
  36943.     // When it takes a while to process a large file,
  36944.     // remember that for each chunk it has to run 
  36945.     // through the main translation loop 16384 times!
  36946.         
  36947.     printf("Processing %ld byte file: .", flen );
  36948.     
  36949.     while( flen > READLEN )
  36950.     {
  36951.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  36952.         {
  36953.             printf("READ ERROR!\n");
  36954.             return;
  36955.         }
  36956.         MD5Translate( lpData, READLEN, &mdDataSum );
  36957.         MD4Translate( lpData, READLEN, &md4DataSum );
  36958.         flen -= READLEN;
  36959.         printf(".");
  36960.     }
  36961.  
  36962.     if (fread( lpData, 1, flen, file ) != flen)
  36963.     {
  36964.         printf("READ ERROR!\n");
  36965.         return;
  36966.     }
  36967.     // This is why I added the new argument to MDxPad
  36968.     // So we can pass the length of the data AND the
  36969.     // Total length of the message
  36970.     // Also it now returns the # of padding bytes added,
  36971.     // this is for files that are an exact multiple of the chunk
  36972.     // length. (Otherwise the padding isn't Translated)
  36973.     flen += MDxPad( lpData, flen, mlen );
  36974.     MD5Translate( lpData, flen, &mdDataSum );    
  36975.     MD4Translate( lpData, flen, &md4DataSum );
  36976.  
  36977.     // New step necessary because of the 'chunking' method
  36978.     MDxFinalize( &mdDataSum );
  36979.     MDxFinalize( &md4DataSum );
  36980.     
  36981.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  36982.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  36983.     fclose(file);
  36984.         
  36985. }
  36986.  
  36987. void DigestString()
  36988. {
  36989.     
  36990.     //For our demo purposes, no strings bigger than 1024 :)
  36991.     unsigned char lpData[1024] = "";
  36992.     long len = 0;
  36993.     MDxSum mdDataSum;
  36994.  
  36995.     printf("Enter the string to digest: ");
  36996.     scanf("%s", &lpData );
  36997.     len = strlen(lpData);
  36998.     
  36999.     // Have to do this before the Padding...well...it's best anyway;)
  37000.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37001.     
  37002.     // For the strings, we're gonna pad and digest the string
  37003.     // in one pass.
  37004.     MDxInit( &mdDataSum );
  37005.     MDxPad( lpData, len, len );
  37006.     
  37007.     MD5Translate( lpData, len, &mdDataSum );
  37008.         // New step necessary because of the 'chunking' method
  37009.         MDxFinalize( &mdDataSum );
  37010.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37011.     
  37012.     MDxInit( &mdDataSum );
  37013.     MD4Translate( lpData, len, &mdDataSum );    
  37014.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37015.  
  37016.     return;
  37017. }
  37018.  
  37019.  
  37020. -------------- Include
  37021.  
  37022. #ifndef __windows_h__
  37023.         typedef unsigned long DWORD;
  37024.         #define STDCALL _stdcall
  37025. #endif
  37026.  
  37027. typedef struct 
  37028. {
  37029.     DWORD dwSum[4];
  37030. }MDxSum;
  37031.  
  37032. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37033. void STDCALL MDxInit( MDxSum * );
  37034. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37035. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37036. const char * STDCALL MDxGetVersion();
  37037. void STDCALL MDxFinalize( MDxSum * );
  37038.  
  37039.  
  37040.  
  37041. #include "mdx.h"
  37042. #include <stdlib.h>
  37043. #include <stdio.h>
  37044. #include <string.h>
  37045.  
  37046. // READLEN % 64 must = 0
  37047. #define READLEN    1048576L // 2^20, 1MB
  37048.  
  37049. void DigestFile( char * );
  37050. void DigestString();
  37051.  
  37052. void main(int argc, char *argv[])
  37053. {
  37054.     printf("%s\n\n", MDxGetVersion());
  37055.  
  37056.     if( argc > 1 )
  37057.         DigestFile( argv[1] );
  37058.     else    
  37059.         DigestString();
  37060.  
  37061. }
  37062.  
  37063. /*
  37064.     I use the 'chunk' method for processing files not because of
  37065.     limitations of my dll, but think what would happen if you
  37066.     tried to load an entire cd image into memory.
  37067. */
  37068. void DigestFile( char *szFName )
  37069. {
  37070.     FILE *file;
  37071.     void *lpData;
  37072.     long flen, mlen;
  37073.     MDxSum mdDataSum;
  37074.     MDxSum md4DataSum;
  37075.  
  37076.     // the 64 is for padding purposes
  37077.     lpData = malloc( READLEN + 64 );
  37078.     
  37079.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  37080.  
  37081.     file = fopen( szFName, "rb" );
  37082.     if( file == NULL )
  37083.     {
  37084.         printf("ERROR: File not found.\n");
  37085.         return;
  37086.     }
  37087.     
  37088.     MDxInit( &mdDataSum );
  37089.     MDxInit( &md4DataSum );
  37090.     
  37091.     fseek( file, 0, SEEK_END );
  37092.     //Get the file length
  37093.     flen = mlen = ftell( file );
  37094.     fseek( file, 0, SEEK_SET );
  37095.     
  37096.     // When it takes a while to process a large file,
  37097.     // remember that for each chunk it has to run 
  37098.     // through the main translation loop 16384 times!
  37099.         
  37100.     printf("Processing %ld byte file: .", flen );
  37101.     
  37102.     while( flen > READLEN )
  37103.     {
  37104.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  37105.         {
  37106.             printf("READ ERROR!\n");
  37107.             return;
  37108.         }
  37109.         MD5Translate( lpData, READLEN, &mdDataSum );
  37110.         MD4Translate( lpData, READLEN, &md4DataSum );
  37111.         flen -= READLEN;
  37112.         printf(".");
  37113.     }
  37114.  
  37115.     if (fread( lpData, 1, flen, file ) != flen)
  37116.     {
  37117.         printf("READ ERROR!\n");
  37118.         return;
  37119.     }
  37120.     // This is why I added the new argument to MDxPad
  37121.     // So we can pass the length of the data AND the
  37122.     // Total length of the message
  37123.     // Also it now returns the # of padding bytes added,
  37124.     // this is for files that are an exact multiple of the chunk
  37125.     // length. (Otherwise the padding isn't Translated)
  37126.     flen += MDxPad( lpData, flen, mlen );
  37127.     MD5Translate( lpData, flen, &mdDataSum );    
  37128.     MD4Translate( lpData, flen, &md4DataSum );
  37129.  
  37130.     // New step necessary because of the 'chunking' method
  37131.     MDxFinalize( &mdDataSum );
  37132.     MDxFinalize( &md4DataSum );
  37133.     
  37134.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  37135.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37136.     fclose(file);
  37137.         
  37138. }
  37139.  
  37140. void DigestString()
  37141. {
  37142.     
  37143.     //For our demo purposes, no strings bigger than 1024 :)
  37144.     unsigned char lpData[1024] = "";
  37145.     long len = 0;
  37146.     MDxSum mdDataSum;
  37147.  
  37148.     printf("Enter the string to digest: ");
  37149.     scanf("%s", &lpData );
  37150.     len = strlen(lpData);
  37151.     
  37152.     // Have to do this before the Padding...well...it's best anyway;)
  37153.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37154.     
  37155.     // For the strings, we're gonna pad and digest the string
  37156.     // in one pass.
  37157.     MDxInit( &mdDataSum );
  37158.     MDxPad( lpData, len, len );
  37159.     
  37160.     MD5Translate( lpData, len, &mdDataSum );
  37161.         // New step necessary because of the 'chunking' method
  37162.         MDxFinalize( &mdDataSum );
  37163.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37164.     
  37165.     MDxInit( &mdDataSum );
  37166.     MD4Translate( lpData, len, &mdDataSum );    
  37167.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37168.  
  37169.     return;
  37170. }
  37171.  
  37172.  
  37173. -------------- Include
  37174.  
  37175. #ifndef __windows_h__
  37176.         typedef unsigned long DWORD;
  37177.         #define STDCALL _stdcall
  37178. #endif
  37179.  
  37180. typedef struct 
  37181. {
  37182.     DWORD dwSum[4];
  37183. }MDxSum;
  37184.  
  37185. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37186. void STDCALL MDxInit( MDxSum * );
  37187. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37188. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37189. const char * STDCALL MDxGetVersion();
  37190. void STDCALL MDxFinalize( MDxSum * );
  37191.  
  37192.  
  37193.  
  37194.  
  37195. #include "mdx.h"
  37196. #include <stdlib.h>
  37197. #include <stdio.h>
  37198. #include <string.h>
  37199.  
  37200. // READLEN % 64 must = 0
  37201. #define READLEN    1048576L // 2^20, 1MB
  37202.  
  37203. void DigestFile( char * );
  37204. void DigestString();
  37205.  
  37206. void main(int argc, char *argv[])
  37207. {
  37208.     printf("%s\n\n", MDxGetVersion());
  37209.  
  37210.     if( argc > 1 )
  37211.         DigestFile( argv[1] );
  37212.     else    
  37213.         DigestString();
  37214.  
  37215. }
  37216.  
  37217. /*
  37218.     I use the 'chunk' method for processing files not because of
  37219.     limitations of my dll, but think what would happen if you
  37220.     tried to load an entire cd image into memory.
  37221. */
  37222. void DigestFile( char *szFName )
  37223. {
  37224.     FILE *file;
  37225.     void *lpData;
  37226.     long flen, mlen;
  37227.     MDxSum mdDataSum;
  37228.     MDxSum md4DataSum;
  37229.  
  37230.     // the 64 is for padding purposes
  37231.     lpData = malloc( READLEN + 64 );
  37232.     
  37233.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  37234.  
  37235.     file = fopen( szFName, "rb" );
  37236.     if( file == NULL )
  37237.     {
  37238.         printf("ERROR: File not found.\n");
  37239.         return;
  37240.     }
  37241.     
  37242.     MDxInit( &mdDataSum );
  37243.     MDxInit( &md4DataSum );
  37244.     
  37245.     fseek( file, 0, SEEK_END );
  37246.     //Get the file length
  37247.     flen = mlen = ftell( file );
  37248.     fseek( file, 0, SEEK_SET );
  37249.     
  37250.     // When it takes a while to process a large file,
  37251.     // remember that for each chunk it has to run 
  37252.     // through the main translation loop 16384 times!
  37253.         
  37254.     printf("Processing %ld byte file: .", flen );
  37255.     
  37256.     while( flen > READLEN )
  37257.     {
  37258.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  37259.         {
  37260.             printf("READ ERROR!\n");
  37261.             return;
  37262.         }
  37263.         MD5Translate( lpData, READLEN, &mdDataSum );
  37264.         MD4Translate( lpData, READLEN, &md4DataSum );
  37265.         flen -= READLEN;
  37266.         printf(".");
  37267.     }
  37268.  
  37269.     if (fread( lpData, 1, flen, file ) != flen)
  37270.     {
  37271.         printf("READ ERROR!\n");
  37272.         return;
  37273.     }
  37274.     // This is why I added the new argument to MDxPad
  37275.     // So we can pass the length of the data AND the
  37276.     // Total length of the message
  37277.     // Also it now returns the # of padding bytes added,
  37278.     // this is for files that are an exact multiple of the chunk
  37279.     // length. (Otherwise the padding isn't Translated)
  37280.     flen += MDxPad( lpData, flen, mlen );
  37281.     MD5Translate( lpData, flen, &mdDataSum );    
  37282.     MD4Translate( lpData, flen, &md4DataSum );
  37283.  
  37284.     // New step necessary because of the 'chunking' method
  37285.     MDxFinalize( &mdDataSum );
  37286.     MDxFinalize( &md4DataSum );
  37287.     
  37288.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  37289.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37290.     fclose(file);
  37291.         
  37292. }
  37293.  
  37294. void DigestString()
  37295. {
  37296.     
  37297.     //For our demo purposes, no strings bigger than 1024 :)
  37298.     unsigned char lpData[1024] = "";
  37299.     long len = 0;
  37300.     MDxSum mdDataSum;
  37301.  
  37302.     printf("Enter the string to digest: ");
  37303.     scanf("%s", &lpData );
  37304.     len = strlen(lpData);
  37305.     
  37306.     // Have to do this before the Padding...well...it's best anyway;)
  37307.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37308.     
  37309.     // For the strings, we're gonna pad and digest the string
  37310.     // in one pass.
  37311.     MDxInit( &mdDataSum );
  37312.     MDxPad( lpData, len, len );
  37313.     
  37314.     MD5Translate( lpData, len, &mdDataSum );
  37315.         // New step necessary because of the 'chunking' method
  37316.         MDxFinalize( &mdDataSum );
  37317.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37318.     
  37319.     MDxInit( &mdDataSum );
  37320.     MD4Translate( lpData, len, &mdDataSum );    
  37321.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37322.  
  37323.     return;
  37324. }
  37325.  
  37326.  
  37327. -------------- Include
  37328.  
  37329. #ifndef __windows_h__
  37330.         typedef unsigned long DWORD;
  37331.         #define STDCALL _stdcall
  37332. #endif
  37333.  
  37334. typedef struct 
  37335. {
  37336.     DWORD dwSum[4];
  37337. }MDxSum;
  37338.  
  37339. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37340. void STDCALL MDxInit( MDxSum * );
  37341. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37342. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37343. const char * STDCALL MDxGetVersion();
  37344. void STDCALL MDxFinalize( MDxSum * );
  37345.  
  37346.  
  37347.  
  37348.  
  37349. #include "mdx.h"
  37350. #include <stdlib.h>
  37351. #include <stdio.h>
  37352. #include <string.h>
  37353.  
  37354. // READLEN % 64 must = 0
  37355. #define READLEN    1048576L // 2^20, 1MB
  37356.  
  37357. void DigestFile( char * );
  37358. void DigestString();
  37359.  
  37360. void main(int argc, char *argv[])
  37361. {
  37362.     printf("%s\n\n", MDxGetVersion());
  37363.  
  37364.     if( argc > 1 )
  37365.         DigestFile( argv[1] );
  37366.     else    
  37367.         DigestString();
  37368.  
  37369. }
  37370.  
  37371. /*
  37372.     I use the 'chunk' method for processing files not because of
  37373.     limitations of my dll, but think what would happen if you
  37374.     tried to load an entire cd image into memory.
  37375. */
  37376. void DigestFile( char *szFName )
  37377. {
  37378.     FILE *file;
  37379.     void *lpData;
  37380.     long flen, mlen;
  37381.     MDxSum mdDataSum;
  37382.     MDxSum md4DataSum;
  37383.  
  37384.     // the 64 is for padding purposes
  37385.     lpData = malloc( READLEN + 64 );
  37386.     
  37387.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  37388.  
  37389.     file = fopen( szFName, "rb" );
  37390.     if( file == NULL )
  37391.     {
  37392.         printf("ERROR: File not found.\n");
  37393.         return;
  37394.     }
  37395.     
  37396.     MDxInit( &mdDataSum );
  37397.     MDxInit( &md4DataSum );
  37398.     
  37399.     fseek( file, 0, SEEK_END );
  37400.     //Get the file length
  37401.     flen = mlen = ftell( file );
  37402.     fseek( file, 0, SEEK_SET );
  37403.     
  37404.     // When it takes a while to process a large file,
  37405.     // remember that for each chunk it has to run 
  37406.     // through the main translation loop 16384 times!
  37407.         
  37408.     printf("Processing %ld byte file: .", flen );
  37409.     
  37410.     while( flen > READLEN )
  37411.     {
  37412.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  37413.         {
  37414.             printf("READ ERROR!\n");
  37415.             return;
  37416.         }
  37417.         MD5Translate( lpData, READLEN, &mdDataSum );
  37418.         MD4Translate( lpData, READLEN, &md4DataSum );
  37419.         flen -= READLEN;
  37420.         printf(".");
  37421.     }
  37422.  
  37423.     if (fread( lpData, 1, flen, file ) != flen)
  37424.     {
  37425.         printf("READ ERROR!\n");
  37426.         return;
  37427.     }
  37428.     // This is why I added the new argument to MDxPad
  37429.     // So we can pass the length of the data AND the
  37430.     // Total length of the message
  37431.     // Also it now returns the # of padding bytes added,
  37432.     // this is for files that are an exact multiple of the chunk
  37433.     // length. (Otherwise the padding isn't Translated)
  37434.     flen += MDxPad( lpData, flen, mlen );
  37435.     MD5Translate( lpData, flen, &mdDataSum );    
  37436.     MD4Translate( lpData, flen, &md4DataSum );
  37437.  
  37438.     // New step necessary because of the 'chunking' method
  37439.     MDxFinalize( &mdDataSum );
  37440.     MDxFinalize( &md4DataSum );
  37441.     
  37442.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  37443.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37444.     fclose(file);
  37445.         
  37446. }
  37447.  
  37448. void DigestString()
  37449. {
  37450.     
  37451.     //For our demo purposes, no strings bigger than 1024 :)
  37452.     unsigned char lpData[1024] = "";
  37453.     long len = 0;
  37454.     MDxSum mdDataSum;
  37455.  
  37456.     printf("Enter the string to digest: ");
  37457.     scanf("%s", &lpData );
  37458.     len = strlen(lpData);
  37459.     
  37460.     // Have to do this before the Padding...well...it's best anyway;)
  37461.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37462.     
  37463.     // For the strings, we're gonna pad and digest the string
  37464.     // in one pass.
  37465.     MDxInit( &mdDataSum );
  37466.     MDxPad( lpData, len, len );
  37467.     
  37468.     MD5Translate( lpData, len, &mdDataSum );
  37469.         // New step necessary because of the 'chunking' method
  37470.         MDxFinalize( &mdDataSum );
  37471.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37472.     
  37473.     MDxInit( &mdDataSum );
  37474.     MD4Translate( lpData, len, &mdDataSum );    
  37475.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37476.  
  37477.     return;
  37478. }
  37479.  
  37480.  
  37481. -------------- Include
  37482.  
  37483. #ifndef __windows_h__
  37484.         typedef unsigned long DWORD;
  37485.         #define STDCALL _stdcall
  37486. #endif
  37487.  
  37488. typedef struct 
  37489. {
  37490.     DWORD dwSum[4];
  37491. }MDxSum;
  37492.  
  37493. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37494. void STDCALL MDxInit( MDxSum * );
  37495. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37496. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37497. const char * STDCALL MDxGetVersion();
  37498. void STDCALL MDxFinalize( MDxSum * );
  37499.  
  37500.  
  37501.  
  37502.  
  37503. #include "mdx.h"
  37504. #include <stdlib.h>
  37505. #include <stdio.h>
  37506. #include <string.h>
  37507.  
  37508. // READLEN % 64 must = 0
  37509. #define READLEN    1048576L // 2^20, 1MB
  37510.  
  37511. void DigestFile( char * );
  37512. void DigestString();
  37513.  
  37514. void main(int argc, char *argv[])
  37515. {
  37516.     printf("%s\n\n", MDxGetVersion());
  37517.  
  37518.     if( argc > 1 )
  37519.         DigestFile( argv[1] );
  37520.     else    
  37521.         DigestString();
  37522.  
  37523. }
  37524.  
  37525. /*
  37526.     I use the 'chunk' method for processing files not because of
  37527.     limitations of my dll, but think what would happen if you
  37528.     tried to load an entire cd image into memory.
  37529. */
  37530. void DigestFile( char *szFName )
  37531. {
  37532.     FILE *file;
  37533.     void *lpData;
  37534.     long flen, mlen;
  37535.     MDxSum mdDataSum;
  37536.     MDxSum md4DataSum;
  37537.  
  37538.     // the 64 is for padding purposes
  37539.     lpData = malloc( READLEN + 64 );
  37540.     
  37541.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  37542.  
  37543.     file = fopen( szFName, "rb" );
  37544.     if( file == NULL )
  37545.     {
  37546.         printf("ERROR: File not found.\n");
  37547.         return;
  37548.     }
  37549.     
  37550.     MDxInit( &mdDataSum );
  37551.     MDxInit( &md4DataSum );
  37552.     
  37553.     fseek( file, 0, SEEK_END );
  37554.     //Get the file length
  37555.     flen = mlen = ftell( file );
  37556.     fseek( file, 0, SEEK_SET );
  37557.     
  37558.     // When it takes a while to process a large file,
  37559.     // remember that for each chunk it has to run 
  37560.     // through the main translation loop 16384 times!
  37561.         
  37562.     printf("Processing %ld byte file: .", flen );
  37563.     
  37564.     while( flen > READLEN )
  37565.     {
  37566.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  37567.         {
  37568.             printf("READ ERROR!\n");
  37569.             return;
  37570.         }
  37571.         MD5Translate( lpData, READLEN, &mdDataSum );
  37572.         MD4Translate( lpData, READLEN, &md4DataSum );
  37573.         flen -= READLEN;
  37574.         printf(".");
  37575.     }
  37576.  
  37577.     if (fread( lpData, 1, flen, file ) != flen)
  37578.     {
  37579.         printf("READ ERROR!\n");
  37580.         return;
  37581.     }
  37582.     // This is why I added the new argument to MDxPad
  37583.     // So we can pass the length of the data AND the
  37584.     // Total length of the message
  37585.     // Also it now returns the # of padding bytes added,
  37586.     // this is for files that are an exact multiple of the chunk
  37587.     // length. (Otherwise the padding isn't Translated)
  37588.     flen += MDxPad( lpData, flen, mlen );
  37589.     MD5Translate( lpData, flen, &mdDataSum );    
  37590.     MD4Translate( lpData, flen, &md4DataSum );
  37591.  
  37592.     // New step necessary because of the 'chunking' method
  37593.     MDxFinalize( &mdDataSum );
  37594.     MDxFinalize( &md4DataSum );
  37595.     
  37596.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  37597.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37598.     fclose(file);
  37599.         
  37600. }
  37601.  
  37602. void DigestString()
  37603. {
  37604.     
  37605.     //For our demo purposes, no strings bigger than 1024 :)
  37606.     unsigned char lpData[1024] = "";
  37607.     long len = 0;
  37608.     MDxSum mdDataSum;
  37609.  
  37610.     printf("Enter the string to digest: ");
  37611.     scanf("%s", &lpData );
  37612.     len = strlen(lpData);
  37613.     
  37614.     // Have to do this before the Padding...well...it's best anyway;)
  37615.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37616.     
  37617.     // For the strings, we're gonna pad and digest the string
  37618.     // in one pass.
  37619.     MDxInit( &mdDataSum );
  37620.     MDxPad( lpData, len, len );
  37621.     
  37622.     MD5Translate( lpData, len, &mdDataSum );
  37623.         // New step necessary because of the 'chunking' method
  37624.         MDxFinalize( &mdDataSum );
  37625.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37626.     
  37627.     MDxInit( &mdDataSum );
  37628.     MD4Translate( lpData, len, &mdDataSum );    
  37629.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37630.  
  37631.     return;
  37632. }
  37633.  
  37634.  
  37635. -------------- Include
  37636.  
  37637. #ifndef __windows_h__
  37638.         typedef unsigned long DWORD;
  37639.         #define STDCALL _stdcall
  37640. #endif
  37641.  
  37642. typedef struct 
  37643. {
  37644.     DWORD dwSum[4];
  37645. }MDxSum;
  37646.  
  37647. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37648. void STDCALL MDxInit( MDxSum * );
  37649. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37650. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37651. const char * STDCALL MDxGetVersion();
  37652. void STDCALL MDxFinalize( MDxSum * );
  37653.  
  37654.  
  37655.  
  37656. #include "mdx.h"
  37657. #include <stdlib.h>
  37658. #include <stdio.h>
  37659. #include <string.h>
  37660.  
  37661. // READLEN % 64 must = 0
  37662. #define READLEN    1048576L // 2^20, 1MB
  37663.  
  37664. void DigestFile( char * );
  37665. void DigestString();
  37666.  
  37667. void main(int argc, char *argv[])
  37668. {
  37669.     printf("%s\n\n", MDxGetVersion());
  37670.  
  37671.     if( argc > 1 )
  37672.         DigestFile( argv[1] );
  37673.     else    
  37674.         DigestString();
  37675.  
  37676. }
  37677.  
  37678. /*
  37679.     I use the 'chunk' method for processing files not because of
  37680.     limitations of my dll, but think what would happen if you
  37681.     tried to load an entire cd image into memory.
  37682. */
  37683. void DigestFile( char *szFName )
  37684. {
  37685.     FILE *file;
  37686.     void *lpData;
  37687.     long flen, mlen;
  37688.     MDxSum mdDataSum;
  37689.     MDxSum md4DataSum;
  37690.  
  37691.     // the 64 is for padding purposes
  37692.     lpData = malloc( READLEN + 64 );
  37693.     
  37694.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  37695.  
  37696.     file = fopen( szFName, "rb" );
  37697.     if( file == NULL )
  37698.     {
  37699.         printf("ERROR: File not found.\n");
  37700.         return;
  37701.     }
  37702.     
  37703.     MDxInit( &mdDataSum );
  37704.     MDxInit( &md4DataSum );
  37705.     
  37706.     fseek( file, 0, SEEK_END );
  37707.     //Get the file length
  37708.     flen = mlen = ftell( file );
  37709.     fseek( file, 0, SEEK_SET );
  37710.     
  37711.     // When it takes a while to process a large file,
  37712.     // remember that for each chunk it has to run 
  37713.     // through the main translation loop 16384 times!
  37714.         
  37715.     printf("Processing %ld byte file: .", flen );
  37716.     
  37717.     while( flen > READLEN )
  37718.     {
  37719.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  37720.         {
  37721.             printf("READ ERROR!\n");
  37722.             return;
  37723.         }
  37724.         MD5Translate( lpData, READLEN, &mdDataSum );
  37725.         MD4Translate( lpData, READLEN, &md4DataSum );
  37726.         flen -= READLEN;
  37727.         printf(".");
  37728.     }
  37729.  
  37730.     if (fread( lpData, 1, flen, file ) != flen)
  37731.     {
  37732.         printf("READ ERROR!\n");
  37733.         return;
  37734.     }
  37735.     // This is why I added the new argument to MDxPad
  37736.     // So we can pass the length of the data AND the
  37737.     // Total length of the message
  37738.     // Also it now returns the # of padding bytes added,
  37739.     // this is for files that are an exact multiple of the chunk
  37740.     // length. (Otherwise the padding isn't Translated)
  37741.     flen += MDxPad( lpData, flen, mlen );
  37742.     MD5Translate( lpData, flen, &mdDataSum );    
  37743.     MD4Translate( lpData, flen, &md4DataSum );
  37744.  
  37745.     // New step necessary because of the 'chunking' method
  37746.     MDxFinalize( &mdDataSum );
  37747.     MDxFinalize( &md4DataSum );
  37748.     
  37749.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  37750.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37751.     fclose(file);
  37752.         
  37753. }
  37754.  
  37755. void DigestString()
  37756. {
  37757.     
  37758.     //For our demo purposes, no strings bigger than 1024 :)
  37759.     unsigned char lpData[1024] = "";
  37760.     long len = 0;
  37761.     MDxSum mdDataSum;
  37762.  
  37763.     printf("Enter the string to digest: ");
  37764.     scanf("%s", &lpData );
  37765.     len = strlen(lpData);
  37766.     
  37767.     // Have to do this before the Padding...well...it's best anyway;)
  37768.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37769.     
  37770.     // For the strings, we're gonna pad and digest the string
  37771.     // in one pass.
  37772.     MDxInit( &mdDataSum );
  37773.     MDxPad( lpData, len, len );
  37774.     
  37775.     MD5Translate( lpData, len, &mdDataSum );
  37776.         // New step necessary because of the 'chunking' method
  37777.         MDxFinalize( &mdDataSum );
  37778.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37779.     
  37780.     MDxInit( &mdDataSum );
  37781.     MD4Translate( lpData, len, &mdDataSum );    
  37782.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37783.  
  37784.     return;
  37785. }
  37786.  
  37787.  
  37788. -------------- Include
  37789.  
  37790. #ifndef __windows_h__
  37791.         typedef unsigned long DWORD;
  37792.         #define STDCALL _stdcall
  37793. #endif
  37794.  
  37795. typedef struct 
  37796. {
  37797.     DWORD dwSum[4];
  37798. }MDxSum;
  37799.  
  37800. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37801. void STDCALL MDxInit( MDxSum * );
  37802. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37803. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37804. const char * STDCALL MDxGetVersion();
  37805. void STDCALL MDxFinalize( MDxSum * );
  37806.  
  37807.  
  37808.  
  37809. #include "mdx.h"
  37810. #include <stdlib.h>
  37811. #include <stdio.h>
  37812. #include <string.h>
  37813.  
  37814. // READLEN % 64 must = 0
  37815. #define READLEN    1048576L // 2^20, 1MB
  37816.  
  37817. void DigestFile( char * );
  37818. void DigestString();
  37819.  
  37820. void main(int argc, char *argv[])
  37821. {
  37822.     printf("%s\n\n", MDxGetVersion());
  37823.  
  37824.     if( argc > 1 )
  37825.         DigestFile( argv[1] );
  37826.     else    
  37827.         DigestString();
  37828.  
  37829. }
  37830.  
  37831. /*
  37832.     I use the 'chunk' method for processing files not because of
  37833.     limitations of my dll, but think what would happen if you
  37834.     tried to load an entire cd image into memory.
  37835. */
  37836. void DigestFile( char *szFName )
  37837. {
  37838.     FILE *file;
  37839.     void *lpData;
  37840.     long flen, mlen;
  37841.     MDxSum mdDataSum;
  37842.     MDxSum md4DataSum;
  37843.  
  37844.     // the 64 is for padding purposes
  37845.     lpData = malloc( READLEN + 64 );
  37846.     
  37847.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  37848.  
  37849.     file = fopen( szFName, "rb" );
  37850.     if( file == NULL )
  37851.     {
  37852.         printf("ERROR: File not found.\n");
  37853.         return;
  37854.     }
  37855.     
  37856.     MDxInit( &mdDataSum );
  37857.     MDxInit( &md4DataSum );
  37858.     
  37859.     fseek( file, 0, SEEK_END );
  37860.     //Get the file length
  37861.     flen = mlen = ftell( file );
  37862.     fseek( file, 0, SEEK_SET );
  37863.     
  37864.     // When it takes a while to process a large file,
  37865.     // remember that for each chunk it has to run 
  37866.     // through the main translation loop 16384 times!
  37867.         
  37868.     printf("Processing %ld byte file: .", flen );
  37869.     
  37870.     while( flen > READLEN )
  37871.     {
  37872.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  37873.         {
  37874.             printf("READ ERROR!\n");
  37875.             return;
  37876.         }
  37877.         MD5Translate( lpData, READLEN, &mdDataSum );
  37878.         MD4Translate( lpData, READLEN, &md4DataSum );
  37879.         flen -= READLEN;
  37880.         printf(".");
  37881.     }
  37882.  
  37883.     if (fread( lpData, 1, flen, file ) != flen)
  37884.     {
  37885.         printf("READ ERROR!\n");
  37886.         return;
  37887.     }
  37888.     // This is why I added the new argument to MDxPad
  37889.     // So we can pass the length of the data AND the
  37890.     // Total length of the message
  37891.     // Also it now returns the # of padding bytes added,
  37892.     // this is for files that are an exact multiple of the chunk
  37893.     // length. (Otherwise the padding isn't Translated)
  37894.     flen += MDxPad( lpData, flen, mlen );
  37895.     MD5Translate( lpData, flen, &mdDataSum );    
  37896.     MD4Translate( lpData, flen, &md4DataSum );
  37897.  
  37898.     // New step necessary because of the 'chunking' method
  37899.     MDxFinalize( &mdDataSum );
  37900.     MDxFinalize( &md4DataSum );
  37901.     
  37902.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  37903.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37904.     fclose(file);
  37905.         
  37906. }
  37907.  
  37908. void DigestString()
  37909. {
  37910.     
  37911.     //For our demo purposes, no strings bigger than 1024 :)
  37912.     unsigned char lpData[1024] = "";
  37913.     long len = 0;
  37914.     MDxSum mdDataSum;
  37915.  
  37916.     printf("Enter the string to digest: ");
  37917.     scanf("%s", &lpData );
  37918.     len = strlen(lpData);
  37919.     
  37920.     // Have to do this before the Padding...well...it's best anyway;)
  37921.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  37922.     
  37923.     // For the strings, we're gonna pad and digest the string
  37924.     // in one pass.
  37925.     MDxInit( &mdDataSum );
  37926.     MDxPad( lpData, len, len );
  37927.     
  37928.     MD5Translate( lpData, len, &mdDataSum );
  37929.         // New step necessary because of the 'chunking' method
  37930.         MDxFinalize( &mdDataSum );
  37931.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37932.     
  37933.     MDxInit( &mdDataSum );
  37934.     MD4Translate( lpData, len, &mdDataSum );    
  37935.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  37936.  
  37937.     return;
  37938. }
  37939.  
  37940.  
  37941. -------------- Include
  37942.  
  37943. #ifndef __windows_h__
  37944.         typedef unsigned long DWORD;
  37945.         #define STDCALL _stdcall
  37946. #endif
  37947.  
  37948. typedef struct 
  37949. {
  37950.     DWORD dwSum[4];
  37951. }MDxSum;
  37952.  
  37953. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  37954. void STDCALL MDxInit( MDxSum * );
  37955. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  37956. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  37957. const char * STDCALL MDxGetVersion();
  37958. void STDCALL MDxFinalize( MDxSum * );
  37959.  
  37960.  
  37961.  
  37962.  
  37963. #include "mdx.h"
  37964. #include <stdlib.h>
  37965. #include <stdio.h>
  37966. #include <string.h>
  37967.  
  37968. // READLEN % 64 must = 0
  37969. #define READLEN    1048576L // 2^20, 1MB
  37970.  
  37971. void DigestFile( char * );
  37972. void DigestString();
  37973.  
  37974. void main(int argc, char *argv[])
  37975. {
  37976.     printf("%s\n\n", MDxGetVersion());
  37977.  
  37978.     if( argc > 1 )
  37979.         DigestFile( argv[1] );
  37980.     else    
  37981.         DigestString();
  37982.  
  37983. }
  37984.  
  37985. /*
  37986.     I use the 'chunk' method for processing files not because of
  37987.     limitations of my dll, but think what would happen if you
  37988.     tried to load an entire cd image into memory.
  37989. */
  37990. void DigestFile( char *szFName )
  37991. {
  37992.     FILE *file;
  37993.     void *lpData;
  37994.     long flen, mlen;
  37995.     MDxSum mdDataSum;
  37996.     MDxSum md4DataSum;
  37997.  
  37998.     // the 64 is for padding purposes
  37999.     lpData = malloc( READLEN + 64 );
  38000.     
  38001.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38002.  
  38003.     file = fopen( szFName, "rb" );
  38004.     if( file == NULL )
  38005.     {
  38006.         printf("ERROR: File not found.\n");
  38007.         return;
  38008.     }
  38009.     
  38010.     MDxInit( &mdDataSum );
  38011.     MDxInit( &md4DataSum );
  38012.     
  38013.     fseek( file, 0, SEEK_END );
  38014.     //Get the file length
  38015.     flen = mlen = ftell( file );
  38016.     fseek( file, 0, SEEK_SET );
  38017.     
  38018.     // When it takes a while to process a large file,
  38019.     // remember that for each chunk it has to run 
  38020.     // through the main translation loop 16384 times!
  38021.         
  38022.     printf("Processing %ld byte file: .", flen );
  38023.     
  38024.     while( flen > READLEN )
  38025.     {
  38026.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38027.         {
  38028.             printf("READ ERROR!\n");
  38029.             return;
  38030.         }
  38031.         MD5Translate( lpData, READLEN, &mdDataSum );
  38032.         MD4Translate( lpData, READLEN, &md4DataSum );
  38033.         flen -= READLEN;
  38034.         printf(".");
  38035.     }
  38036.  
  38037.     if (fread( lpData, 1, flen, file ) != flen)
  38038.     {
  38039.         printf("READ ERROR!\n");
  38040.         return;
  38041.     }
  38042.     // This is why I added the new argument to MDxPad
  38043.     // So we can pass the length of the data AND the
  38044.     // Total length of the message
  38045.     // Also it now returns the # of padding bytes added,
  38046.     // this is for files that are an exact multiple of the chunk
  38047.     // length. (Otherwise the padding isn't Translated)
  38048.     flen += MDxPad( lpData, flen, mlen );
  38049.     MD5Translate( lpData, flen, &mdDataSum );    
  38050.     MD4Translate( lpData, flen, &md4DataSum );
  38051.  
  38052.     // New step necessary because of the 'chunking' method
  38053.     MDxFinalize( &mdDataSum );
  38054.     MDxFinalize( &md4DataSum );
  38055.     
  38056.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38057.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38058.     fclose(file);
  38059.         
  38060. }
  38061.  
  38062. void DigestString()
  38063. {
  38064.     
  38065.     //For our demo purposes, no strings bigger than 1024 :)
  38066.     unsigned char lpData[1024] = "";
  38067.     long len = 0;
  38068.     MDxSum mdDataSum;
  38069.  
  38070.     printf("Enter the string to digest: ");
  38071.     scanf("%s", &lpData );
  38072.     len = strlen(lpData);
  38073.     
  38074.     // Have to do this before the Padding...well...it's best anyway;)
  38075.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38076.     
  38077.     // For the strings, we're gonna pad and digest the string
  38078.     // in one pass.
  38079.     MDxInit( &mdDataSum );
  38080.     MDxPad( lpData, len, len );
  38081.     
  38082.     MD5Translate( lpData, len, &mdDataSum );
  38083.         // New step necessary because of the 'chunking' method
  38084.         MDxFinalize( &mdDataSum );
  38085.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38086.     
  38087.     MDxInit( &mdDataSum );
  38088.     MD4Translate( lpData, len, &mdDataSum );    
  38089.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38090.  
  38091.     return;
  38092. }
  38093.  
  38094.  
  38095. -------------- Include
  38096.  
  38097. #ifndef __windows_h__
  38098.         typedef unsigned long DWORD;
  38099.         #define STDCALL _stdcall
  38100. #endif
  38101.  
  38102. typedef struct 
  38103. {
  38104.     DWORD dwSum[4];
  38105. }MDxSum;
  38106.  
  38107. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  38108. void STDCALL MDxInit( MDxSum * );
  38109. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  38110. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  38111. const char * STDCALL MDxGetVersion();
  38112. void STDCALL MDxFinalize( MDxSum * );
  38113.  
  38114.  
  38115.  
  38116.  
  38117. #include "mdx.h"
  38118. #include <stdlib.h>
  38119. #include <stdio.h>
  38120. #include <string.h>
  38121.  
  38122. // READLEN % 64 must = 0
  38123. #define READLEN    1048576L // 2^20, 1MB
  38124.  
  38125. void DigestFile( char * );
  38126. void DigestString();
  38127.  
  38128. void main(int argc, char *argv[])
  38129. {
  38130.     printf("%s\n\n", MDxGetVersion());
  38131.  
  38132.     if( argc > 1 )
  38133.         DigestFile( argv[1] );
  38134.     else    
  38135.         DigestString();
  38136.  
  38137. }
  38138.  
  38139. /*
  38140.     I use the 'chunk' method for processing files not because of
  38141.     limitations of my dll, but think what would happen if you
  38142.     tried to load an entire cd image into memory.
  38143. */
  38144. void DigestFile( char *szFName )
  38145. {
  38146.     FILE *file;
  38147.     void *lpData;
  38148.     long flen, mlen;
  38149.     MDxSum mdDataSum;
  38150.     MDxSum md4DataSum;
  38151.  
  38152.     // the 64 is for padding purposes
  38153.     lpData = malloc( READLEN + 64 );
  38154.     
  38155.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38156.  
  38157.     file = fopen( szFName, "rb" );
  38158.     if( file == NULL )
  38159.     {
  38160.         printf("ERROR: File not found.\n");
  38161.         return;
  38162.     }
  38163.     
  38164.     MDxInit( &mdDataSum );
  38165.     MDxInit( &md4DataSum );
  38166.     
  38167.     fseek( file, 0, SEEK_END );
  38168.     //Get the file length
  38169.     flen = mlen = ftell( file );
  38170.     fseek( file, 0, SEEK_SET );
  38171.     
  38172.     // When it takes a while to process a large file,
  38173.     // remember that for each chunk it has to run 
  38174.     // through the main translation loop 16384 times!
  38175.         
  38176.     printf("Processing %ld byte file: .", flen );
  38177.     
  38178.     while( flen > READLEN )
  38179.     {
  38180.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38181.         {
  38182.             printf("READ ERROR!\n");
  38183.             return;
  38184.         }
  38185.         MD5Translate( lpData, READLEN, &mdDataSum );
  38186.         MD4Translate( lpData, READLEN, &md4DataSum );
  38187.         flen -= READLEN;
  38188.         printf(".");
  38189.     }
  38190.  
  38191.     if (fread( lpData, 1, flen, file ) != flen)
  38192.     {
  38193.         printf("READ ERROR!\n");
  38194.         return;
  38195.     }
  38196.     // This is why I added the new argument to MDxPad
  38197.     // So we can pass the length of the data AND the
  38198.     // Total length of the message
  38199.     // Also it now returns the # of padding bytes added,
  38200.     // this is for files that are an exact multiple of the chunk
  38201.     // length. (Otherwise the padding isn't Translated)
  38202.     flen += MDxPad( lpData, flen, mlen );
  38203.     MD5Translate( lpData, flen, &mdDataSum );    
  38204.     MD4Translate( lpData, flen, &md4DataSum );
  38205.  
  38206.     // New step necessary because of the 'chunking' method
  38207.     MDxFinalize( &mdDataSum );
  38208.     MDxFinalize( &md4DataSum );
  38209.     
  38210.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38211.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38212.     fclose(file);
  38213.         
  38214. }
  38215.  
  38216. void DigestString()
  38217. {
  38218.     
  38219.     //For our demo purposes, no strings bigger than 1024 :)
  38220.     unsigned char lpData[1024] = "";
  38221.     long len = 0;
  38222.     MDxSum mdDataSum;
  38223.  
  38224.     printf("Enter the string to digest: ");
  38225.     scanf("%s", &lpData );
  38226.     len = strlen(lpData);
  38227.     
  38228.     // Have to do this before the Padding...well...it's best anyway;)
  38229.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38230.     
  38231.     // For the strings, we're gonna pad and digest the string
  38232.     // in one pass.
  38233.     MDxInit( &mdDataSum );
  38234.     MDxPad( lpData, len, len );
  38235.     
  38236.     MD5Translate( lpData, len, &mdDataSum );
  38237.         // New step necessary because of the 'chunking' method
  38238.         MDxFinalize( &mdDataSum );
  38239.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38240.     
  38241.     MDxInit( &mdDataSum );
  38242.     MD4Translate( lpData, len, &mdDataSum );    
  38243.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38244.  
  38245.     return;
  38246. }
  38247.  
  38248.  
  38249. -------------- Include
  38250.  
  38251. #ifndef __windows_h__
  38252.         typedef unsigned long DWORD;
  38253.         #define STDCALL _stdcall
  38254. #endif
  38255.  
  38256. typedef struct 
  38257. {
  38258.     DWORD dwSum[4];
  38259. }MDxSum;
  38260.  
  38261. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  38262. void STDCALL MDxInit( MDxSum * );
  38263. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  38264. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  38265. const char * STDCALL MDxGetVersion();
  38266. void STDCALL MDxFinalize( MDxSum * );
  38267.  
  38268.  
  38269.  
  38270.  
  38271. #include "mdx.h"
  38272. #include <stdlib.h>
  38273. #include <stdio.h>
  38274. #include <string.h>
  38275.  
  38276. // READLEN % 64 must = 0
  38277. #define READLEN    1048576L // 2^20, 1MB
  38278.  
  38279. void DigestFile( char * );
  38280. void DigestString();
  38281.  
  38282. void main(int argc, char *argv[])
  38283. {
  38284.     printf("%s\n\n", MDxGetVersion());
  38285.  
  38286.     if( argc > 1 )
  38287.         DigestFile( argv[1] );
  38288.     else    
  38289.         DigestString();
  38290.  
  38291. }
  38292.  
  38293. /*
  38294.     I use the 'chunk' method for processing files not because of
  38295.     limitations of my dll, but think what would happen if you
  38296.     tried to load an entire cd image into memory.
  38297. */
  38298. void DigestFile( char *szFName )
  38299. {
  38300.     FILE *file;
  38301.     void *lpData;
  38302.     long flen, mlen;
  38303.     MDxSum mdDataSum;
  38304.     MDxSum md4DataSum;
  38305.  
  38306.     // the 64 is for padding purposes
  38307.     lpData = malloc( READLEN + 64 );
  38308.     
  38309.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38310.  
  38311.     file = fopen( szFName, "rb" );
  38312.     if( file == NULL )
  38313.     {
  38314.         printf("ERROR: File not found.\n");
  38315.         return;
  38316.     }
  38317.     
  38318.     MDxInit( &mdDataSum );
  38319.     MDxInit( &md4DataSum );
  38320.     
  38321.     fseek( file, 0, SEEK_END );
  38322.     //Get the file length
  38323.     flen = mlen = ftell( file );
  38324.     fseek( file, 0, SEEK_SET );
  38325.     
  38326.     // When it takes a while to process a large file,
  38327.     // remember that for each chunk it has to run 
  38328.     // through the main translation loop 16384 times!
  38329.         
  38330.     printf("Processing %ld byte file: .", flen );
  38331.     
  38332.     while( flen > READLEN )
  38333.     {
  38334.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38335.         {
  38336.             printf("READ ERROR!\n");
  38337.             return;
  38338.         }
  38339.         MD5Translate( lpData, READLEN, &mdDataSum );
  38340.         MD4Translate( lpData, READLEN, &md4DataSum );
  38341.         flen -= READLEN;
  38342.         printf(".");
  38343.     }
  38344.  
  38345.     if (fread( lpData, 1, flen, file ) != flen)
  38346.     {
  38347.         printf("READ ERROR!\n");
  38348.         return;
  38349.     }
  38350.     // This is why I added the new argument to MDxPad
  38351.     // So we can pass the length of the data AND the
  38352.     // Total length of the message
  38353.     // Also it now returns the # of padding bytes added,
  38354.     // this is for files that are an exact multiple of the chunk
  38355.     // length. (Otherwise the padding isn't Translated)
  38356.     flen += MDxPad( lpData, flen, mlen );
  38357.     MD5Translate( lpData, flen, &mdDataSum );    
  38358.     MD4Translate( lpData, flen, &md4DataSum );
  38359.  
  38360.     // New step necessary because of the 'chunking' method
  38361.     MDxFinalize( &mdDataSum );
  38362.     MDxFinalize( &md4DataSum );
  38363.     
  38364.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38365.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38366.     fclose(file);
  38367.         
  38368. }
  38369.  
  38370. void DigestString()
  38371. {
  38372.     
  38373.     //For our demo purposes, no strings bigger than 1024 :)
  38374.     unsigned char lpData[1024] = "";
  38375.     long len = 0;
  38376.     MDxSum mdDataSum;
  38377.  
  38378.     printf("Enter the string to digest: ");
  38379.     scanf("%s", &lpData );
  38380.     len = strlen(lpData);
  38381.     
  38382.     // Have to do this before the Padding...well...it's best anyway;)
  38383.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38384.     
  38385.     // For the strings, we're gonna pad and digest the string
  38386.     // in one pass.
  38387.     MDxInit( &mdDataSum );
  38388.     MDxPad( lpData, len, len );
  38389.     
  38390.     MD5Translate( lpData, len, &mdDataSum );
  38391.         // New step necessary because of the 'chunking' method
  38392.         MDxFinalize( &mdDataSum );
  38393.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38394.     
  38395.     MDxInit( &mdDataSum );
  38396.     MD4Translate( lpData, len, &mdDataSum );    
  38397.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38398.  
  38399.     return;
  38400. }
  38401.  
  38402.  
  38403. -------------- Include
  38404.  
  38405. #ifndef __windows_h__
  38406.         typedef unsigned long DWORD;
  38407.         #define STDCALL _stdcall
  38408. #endif
  38409.  
  38410. typedef struct 
  38411. {
  38412.     DWORD dwSum[4];
  38413. }MDxSum;
  38414.  
  38415. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  38416. void STDCALL MDxInit( MDxSum * );
  38417. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  38418. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  38419. const char * STDCALL MDxGetVersion();
  38420. void STDCALL MDxFinalize( MDxSum * );
  38421.  
  38422.  
  38423.  
  38424. #include "mdx.h"
  38425. #include <stdlib.h>
  38426. #include <stdio.h>
  38427. #include <string.h>
  38428.  
  38429. // READLEN % 64 must = 0
  38430. #define READLEN    1048576L // 2^20, 1MB
  38431.  
  38432. void DigestFile( char * );
  38433. void DigestString();
  38434.  
  38435. void main(int argc, char *argv[])
  38436. {
  38437.     printf("%s\n\n", MDxGetVersion());
  38438.  
  38439.     if( argc > 1 )
  38440.         DigestFile( argv[1] );
  38441.     else    
  38442.         DigestString();
  38443.  
  38444. }
  38445.  
  38446. /*
  38447.     I use the 'chunk' method for processing files not because of
  38448.     limitations of my dll, but think what would happen if you
  38449.     tried to load an entire cd image into memory.
  38450. */
  38451. void DigestFile( char *szFName )
  38452. {
  38453.     FILE *file;
  38454.     void *lpData;
  38455.     long flen, mlen;
  38456.     MDxSum mdDataSum;
  38457.     MDxSum md4DataSum;
  38458.  
  38459.     // the 64 is for padding purposes
  38460.     lpData = malloc( READLEN + 64 );
  38461.     
  38462.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38463.  
  38464.     file = fopen( szFName, "rb" );
  38465.     if( file == NULL )
  38466.     {
  38467.         printf("ERROR: File not found.\n");
  38468.         return;
  38469.     }
  38470.     
  38471.     MDxInit( &mdDataSum );
  38472.     MDxInit( &md4DataSum );
  38473.     
  38474.     fseek( file, 0, SEEK_END );
  38475.     //Get the file length
  38476.     flen = mlen = ftell( file );
  38477.     fseek( file, 0, SEEK_SET );
  38478.     
  38479.     // When it takes a while to process a large file,
  38480.     // remember that for each chunk it has to run 
  38481.     // through the main translation loop 16384 times!
  38482.         
  38483.     printf("Processing %ld byte file: .", flen );
  38484.     
  38485.     while( flen > READLEN )
  38486.     {
  38487.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38488.         {
  38489.             printf("READ ERROR!\n");
  38490.             return;
  38491.         }
  38492.         MD5Translate( lpData, READLEN, &mdDataSum );
  38493.         MD4Translate( lpData, READLEN, &md4DataSum );
  38494.         flen -= READLEN;
  38495.         printf(".");
  38496.     }
  38497.  
  38498.     if (fread( lpData, 1, flen, file ) != flen)
  38499.     {
  38500.         printf("READ ERROR!\n");
  38501.         return;
  38502.     }
  38503.     // This is why I added the new argument to MDxPad
  38504.     // So we can pass the length of the data AND the
  38505.     // Total length of the message
  38506.     // Also it now returns the # of padding bytes added,
  38507.     // this is for files that are an exact multiple of the chunk
  38508.     // length. (Otherwise the padding isn't Translated)
  38509.     flen += MDxPad( lpData, flen, mlen );
  38510.     MD5Translate( lpData, flen, &mdDataSum );    
  38511.     MD4Translate( lpData, flen, &md4DataSum );
  38512.  
  38513.     // New step necessary because of the 'chunking' method
  38514.     MDxFinalize( &mdDataSum );
  38515.     MDxFinalize( &md4DataSum );
  38516.     
  38517.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38518.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38519.     fclose(file);
  38520.         
  38521. }
  38522.  
  38523. void DigestString()
  38524. {
  38525.     
  38526.     //For our demo purposes, no strings bigger than 1024 :)
  38527.     unsigned char lpData[1024] = "";
  38528.     long len = 0;
  38529.     MDxSum mdDataSum;
  38530.  
  38531.     printf("Enter the string to digest: ");
  38532.     scanf("%s", &lpData );
  38533.     len = strlen(lpData);
  38534.     
  38535.     // Have to do this before the Padding...well...it's best anyway;)
  38536.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38537.     
  38538.     // For the strings, we're gonna pad and digest the string
  38539.     // in one pass.
  38540.     MDxInit( &mdDataSum );
  38541.     MDxPad( lpData, len, len );
  38542.     
  38543.     MD5Translate( lpData, len, &mdDataSum );
  38544.         // New step necessary because of the 'chunking' method
  38545.         MDxFinalize( &mdDataSum );
  38546.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38547.     
  38548.     MDxInit( &mdDataSum );
  38549.     MD4Translate( lpData, len, &mdDataSum );    
  38550.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38551.  
  38552.     return;
  38553. }
  38554.  
  38555.  
  38556. -------------- Include
  38557.  
  38558. #ifndef __windows_h__
  38559.         typedef unsigned long DWORD;
  38560.         #define STDCALL _stdcall
  38561. #endif
  38562.  
  38563. typedef struct 
  38564. {
  38565.     DWORD dwSum[4];
  38566. }MDxSum;
  38567.  
  38568. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  38569. void STDCALL MDxInit( MDxSum * );
  38570. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  38571. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  38572. const char * STDCALL MDxGetVersion();
  38573. void STDCALL MDxFinalize( MDxSum * );
  38574.  
  38575.  
  38576.  
  38577. #include "mdx.h"
  38578. #include <stdlib.h>
  38579. #include <stdio.h>
  38580. #include <string.h>
  38581.  
  38582. // READLEN % 64 must = 0
  38583. #define READLEN    1048576L // 2^20, 1MB
  38584.  
  38585. void DigestFile( char * );
  38586. void DigestString();
  38587.  
  38588. void main(int argc, char *argv[])
  38589. {
  38590.     printf("%s\n\n", MDxGetVersion());
  38591.  
  38592.     if( argc > 1 )
  38593.         DigestFile( argv[1] );
  38594.     else    
  38595.         DigestString();
  38596.  
  38597. }
  38598.  
  38599. /*
  38600.     I use the 'chunk' method for processing files not because of
  38601.     limitations of my dll, but think what would happen if you
  38602.     tried to load an entire cd image into memory.
  38603. */
  38604. void DigestFile( char *szFName )
  38605. {
  38606.     FILE *file;
  38607.     void *lpData;
  38608.     long flen, mlen;
  38609.     MDxSum mdDataSum;
  38610.     MDxSum md4DataSum;
  38611.  
  38612.     // the 64 is for padding purposes
  38613.     lpData = malloc( READLEN + 64 );
  38614.     
  38615.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38616.  
  38617.     file = fopen( szFName, "rb" );
  38618.     if( file == NULL )
  38619.     {
  38620.         printf("ERROR: File not found.\n");
  38621.         return;
  38622.     }
  38623.     
  38624.     MDxInit( &mdDataSum );
  38625.     MDxInit( &md4DataSum );
  38626.     
  38627.     fseek( file, 0, SEEK_END );
  38628.     //Get the file length
  38629.     flen = mlen = ftell( file );
  38630.     fseek( file, 0, SEEK_SET );
  38631.     
  38632.     // When it takes a while to process a large file,
  38633.     // remember that for each chunk it has to run 
  38634.     // through the main translation loop 16384 times!
  38635.         
  38636.     printf("Processing %ld byte file: .", flen );
  38637.     
  38638.     while( flen > READLEN )
  38639.     {
  38640.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38641.         {
  38642.             printf("READ ERROR!\n");
  38643.             return;
  38644.         }
  38645.         MD5Translate( lpData, READLEN, &mdDataSum );
  38646.         MD4Translate( lpData, READLEN, &md4DataSum );
  38647.         flen -= READLEN;
  38648.         printf(".");
  38649.     }
  38650.  
  38651.     if (fread( lpData, 1, flen, file ) != flen)
  38652.     {
  38653.         printf("READ ERROR!\n");
  38654.         return;
  38655.     }
  38656.     // This is why I added the new argument to MDxPad
  38657.     // So we can pass the length of the data AND the
  38658.     // Total length of the message
  38659.     // Also it now returns the # of padding bytes added,
  38660.     // this is for files that are an exact multiple of the chunk
  38661.     // length. (Otherwise the padding isn't Translated)
  38662.     flen += MDxPad( lpData, flen, mlen );
  38663.     MD5Translate( lpData, flen, &mdDataSum );    
  38664.     MD4Translate( lpData, flen, &md4DataSum );
  38665.  
  38666.     // New step necessary because of the 'chunking' method
  38667.     MDxFinalize( &mdDataSum );
  38668.     MDxFinalize( &md4DataSum );
  38669.     
  38670.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38671.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38672.     fclose(file);
  38673.         
  38674. }
  38675.  
  38676. void DigestString()
  38677. {
  38678.     
  38679.     //For our demo purposes, no strings bigger than 1024 :)
  38680.     unsigned char lpData[1024] = "";
  38681.     long len = 0;
  38682.     MDxSum mdDataSum;
  38683.  
  38684.     printf("Enter the string to digest: ");
  38685.     scanf("%s", &lpData );
  38686.     len = strlen(lpData);
  38687.     
  38688.     // Have to do this before the Padding...well...it's best anyway;)
  38689.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38690.     
  38691.     // For the strings, we're gonna pad and digest the string
  38692.     // in one pass.
  38693.     MDxInit( &mdDataSum );
  38694.     MDxPad( lpData, len, len );
  38695.     
  38696.     MD5Translate( lpData, len, &mdDataSum );
  38697.         // New step necessary because of the 'chunking' method
  38698.         MDxFinalize( &mdDataSum );
  38699.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38700.     
  38701.     MDxInit( &mdDataSum );
  38702.     MD4Translate( lpData, len, &mdDataSum );    
  38703.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38704.  
  38705.     return;
  38706. }
  38707.  
  38708.  
  38709. -------------- Include
  38710.  
  38711. #ifndef __windows_h__
  38712.         typedef unsigned long DWORD;
  38713.         #define STDCALL _stdcall
  38714. #endif
  38715.  
  38716. typedef struct 
  38717. {
  38718.     DWORD dwSum[4];
  38719. }MDxSum;
  38720.  
  38721. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  38722. void STDCALL MDxInit( MDxSum * );
  38723. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  38724. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  38725. const char * STDCALL MDxGetVersion();
  38726. void STDCALL MDxFinalize( MDxSum * );
  38727.  
  38728.  
  38729.  
  38730.  
  38731. #include "mdx.h"
  38732. #include <stdlib.h>
  38733. #include <stdio.h>
  38734. #include <string.h>
  38735.  
  38736. // READLEN % 64 must = 0
  38737. #define READLEN    1048576L // 2^20, 1MB
  38738.  
  38739. void DigestFile( char * );
  38740. void DigestString();
  38741.  
  38742. void main(int argc, char *argv[])
  38743. {
  38744.     printf("%s\n\n", MDxGetVersion());
  38745.  
  38746.     if( argc > 1 )
  38747.         DigestFile( argv[1] );
  38748.     else    
  38749.         DigestString();
  38750.  
  38751. }
  38752.  
  38753. /*
  38754.     I use the 'chunk' method for processing files not because of
  38755.     limitations of my dll, but think what would happen if you
  38756.     tried to load an entire cd image into memory.
  38757. */
  38758. void DigestFile( char *szFName )
  38759. {
  38760.     FILE *file;
  38761.     void *lpData;
  38762.     long flen, mlen;
  38763.     MDxSum mdDataSum;
  38764.     MDxSum md4DataSum;
  38765.  
  38766.     // the 64 is for padding purposes
  38767.     lpData = malloc( READLEN + 64 );
  38768.     
  38769.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38770.  
  38771.     file = fopen( szFName, "rb" );
  38772.     if( file == NULL )
  38773.     {
  38774.         printf("ERROR: File not found.\n");
  38775.         return;
  38776.     }
  38777.     
  38778.     MDxInit( &mdDataSum );
  38779.     MDxInit( &md4DataSum );
  38780.     
  38781.     fseek( file, 0, SEEK_END );
  38782.     //Get the file length
  38783.     flen = mlen = ftell( file );
  38784.     fseek( file, 0, SEEK_SET );
  38785.     
  38786.     // When it takes a while to process a large file,
  38787.     // remember that for each chunk it has to run 
  38788.     // through the main translation loop 16384 times!
  38789.         
  38790.     printf("Processing %ld byte file: .", flen );
  38791.     
  38792.     while( flen > READLEN )
  38793.     {
  38794.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38795.         {
  38796.             printf("READ ERROR!\n");
  38797.             return;
  38798.         }
  38799.         MD5Translate( lpData, READLEN, &mdDataSum );
  38800.         MD4Translate( lpData, READLEN, &md4DataSum );
  38801.         flen -= READLEN;
  38802.         printf(".");
  38803.     }
  38804.  
  38805.     if (fread( lpData, 1, flen, file ) != flen)
  38806.     {
  38807.         printf("READ ERROR!\n");
  38808.         return;
  38809.     }
  38810.     // This is why I added the new argument to MDxPad
  38811.     // So we can pass the length of the data AND the
  38812.     // Total length of the message
  38813.     // Also it now returns the # of padding bytes added,
  38814.     // this is for files that are an exact multiple of the chunk
  38815.     // length. (Otherwise the padding isn't Translated)
  38816.     flen += MDxPad( lpData, flen, mlen );
  38817.     MD5Translate( lpData, flen, &mdDataSum );    
  38818.     MD4Translate( lpData, flen, &md4DataSum );
  38819.  
  38820.     // New step necessary because of the 'chunking' method
  38821.     MDxFinalize( &mdDataSum );
  38822.     MDxFinalize( &md4DataSum );
  38823.     
  38824.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38825.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38826.     fclose(file);
  38827.         
  38828. }
  38829.  
  38830. void DigestString()
  38831. {
  38832.     
  38833.     //For our demo purposes, no strings bigger than 1024 :)
  38834.     unsigned char lpData[1024] = "";
  38835.     long len = 0;
  38836.     MDxSum mdDataSum;
  38837.  
  38838.     printf("Enter the string to digest: ");
  38839.     scanf("%s", &lpData );
  38840.     len = strlen(lpData);
  38841.     
  38842.     // Have to do this before the Padding...well...it's best anyway;)
  38843.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38844.     
  38845.     // For the strings, we're gonna pad and digest the string
  38846.     // in one pass.
  38847.     MDxInit( &mdDataSum );
  38848.     MDxPad( lpData, len, len );
  38849.     
  38850.     MD5Translate( lpData, len, &mdDataSum );
  38851.         // New step necessary because of the 'chunking' method
  38852.         MDxFinalize( &mdDataSum );
  38853.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38854.     
  38855.     MDxInit( &mdDataSum );
  38856.     MD4Translate( lpData, len, &mdDataSum );    
  38857.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38858.  
  38859.     return;
  38860. }
  38861.  
  38862.  
  38863. -------------- Include
  38864.  
  38865. #ifndef __windows_h__
  38866.         typedef unsigned long DWORD;
  38867.         #define STDCALL _stdcall
  38868. #endif
  38869.  
  38870. typedef struct 
  38871. {
  38872.     DWORD dwSum[4];
  38873. }MDxSum;
  38874.  
  38875. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  38876. void STDCALL MDxInit( MDxSum * );
  38877. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  38878. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  38879. const char * STDCALL MDxGetVersion();
  38880. void STDCALL MDxFinalize( MDxSum * );
  38881.  
  38882.  
  38883.  
  38884. #include "mdx.h"
  38885. #include <stdlib.h>
  38886. #include <stdio.h>
  38887. #include <string.h>
  38888.  
  38889. // READLEN % 64 must = 0
  38890. #define READLEN    1048576L // 2^20, 1MB
  38891.  
  38892. void DigestFile( char * );
  38893. void DigestString();
  38894.  
  38895. void main(int argc, char *argv[])
  38896. {
  38897.     printf("%s\n\n", MDxGetVersion());
  38898.  
  38899.     if( argc > 1 )
  38900.         DigestFile( argv[1] );
  38901.     else    
  38902.         DigestString();
  38903.  
  38904. }
  38905.  
  38906. /*
  38907.     I use the 'chunk' method for processing files not because of
  38908.     limitations of my dll, but think what would happen if you
  38909.     tried to load an entire cd image into memory.
  38910. */
  38911. void DigestFile( char *szFName )
  38912. {
  38913.     FILE *file;
  38914.     void *lpData;
  38915.     long flen, mlen;
  38916.     MDxSum mdDataSum;
  38917.     MDxSum md4DataSum;
  38918.  
  38919.     // the 64 is for padding purposes
  38920.     lpData = malloc( READLEN + 64 );
  38921.     
  38922.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  38923.  
  38924.     file = fopen( szFName, "rb" );
  38925.     if( file == NULL )
  38926.     {
  38927.         printf("ERROR: File not found.\n");
  38928.         return;
  38929.     }
  38930.     
  38931.     MDxInit( &mdDataSum );
  38932.     MDxInit( &md4DataSum );
  38933.     
  38934.     fseek( file, 0, SEEK_END );
  38935.     //Get the file length
  38936.     flen = mlen = ftell( file );
  38937.     fseek( file, 0, SEEK_SET );
  38938.     
  38939.     // When it takes a while to process a large file,
  38940.     // remember that for each chunk it has to run 
  38941.     // through the main translation loop 16384 times!
  38942.         
  38943.     printf("Processing %ld byte file: .", flen );
  38944.     
  38945.     while( flen > READLEN )
  38946.     {
  38947.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  38948.         {
  38949.             printf("READ ERROR!\n");
  38950.             return;
  38951.         }
  38952.         MD5Translate( lpData, READLEN, &mdDataSum );
  38953.         MD4Translate( lpData, READLEN, &md4DataSum );
  38954.         flen -= READLEN;
  38955.         printf(".");
  38956.     }
  38957.  
  38958.     if (fread( lpData, 1, flen, file ) != flen)
  38959.     {
  38960.         printf("READ ERROR!\n");
  38961.         return;
  38962.     }
  38963.     // This is why I added the new argument to MDxPad
  38964.     // So we can pass the length of the data AND the
  38965.     // Total length of the message
  38966.     // Also it now returns the # of padding bytes added,
  38967.     // this is for files that are an exact multiple of the chunk
  38968.     // length. (Otherwise the padding isn't Translated)
  38969.     flen += MDxPad( lpData, flen, mlen );
  38970.     MD5Translate( lpData, flen, &mdDataSum );    
  38971.     MD4Translate( lpData, flen, &md4DataSum );
  38972.  
  38973.     // New step necessary because of the 'chunking' method
  38974.     MDxFinalize( &mdDataSum );
  38975.     MDxFinalize( &md4DataSum );
  38976.     
  38977.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  38978.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  38979.     fclose(file);
  38980.         
  38981. }
  38982.  
  38983. void DigestString()
  38984. {
  38985.     
  38986.     //For our demo purposes, no strings bigger than 1024 :)
  38987.     unsigned char lpData[1024] = "";
  38988.     long len = 0;
  38989.     MDxSum mdDataSum;
  38990.  
  38991.     printf("Enter the string to digest: ");
  38992.     scanf("%s", &lpData );
  38993.     len = strlen(lpData);
  38994.     
  38995.     // Have to do this before the Padding...well...it's best anyway;)
  38996.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  38997.     
  38998.     // For the strings, we're gonna pad and digest the string
  38999.     // in one pass.
  39000.     MDxInit( &mdDataSum );
  39001.     MDxPad( lpData, len, len );
  39002.     
  39003.     MD5Translate( lpData, len, &mdDataSum );
  39004.         // New step necessary because of the 'chunking' method
  39005.         MDxFinalize( &mdDataSum );
  39006.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39007.     
  39008.     MDxInit( &mdDataSum );
  39009.     MD4Translate( lpData, len, &mdDataSum );    
  39010.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39011.  
  39012.     return;
  39013. }
  39014.  
  39015.  
  39016. -------------- Include
  39017.  
  39018. #ifndef __windows_h__
  39019.         typedef unsigned long DWORD;
  39020.         #define STDCALL _stdcall
  39021. #endif
  39022.  
  39023. typedef struct 
  39024. {
  39025.     DWORD dwSum[4];
  39026. }MDxSum;
  39027.  
  39028. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39029. void STDCALL MDxInit( MDxSum * );
  39030. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39031. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39032. const char * STDCALL MDxGetVersion();
  39033. void STDCALL MDxFinalize( MDxSum * );
  39034.  
  39035.  
  39036.  
  39037.  
  39038. #include "mdx.h"
  39039. #include <stdlib.h>
  39040. #include <stdio.h>
  39041. #include <string.h>
  39042.  
  39043. // READLEN % 64 must = 0
  39044. #define READLEN    1048576L // 2^20, 1MB
  39045.  
  39046. void DigestFile( char * );
  39047. void DigestString();
  39048.  
  39049. void main(int argc, char *argv[])
  39050. {
  39051.     printf("%s\n\n", MDxGetVersion());
  39052.  
  39053.     if( argc > 1 )
  39054.         DigestFile( argv[1] );
  39055.     else    
  39056.         DigestString();
  39057.  
  39058. }
  39059.  
  39060. /*
  39061.     I use the 'chunk' method for processing files not because of
  39062.     limitations of my dll, but think what would happen if you
  39063.     tried to load an entire cd image into memory.
  39064. */
  39065. void DigestFile( char *szFName )
  39066. {
  39067.     FILE *file;
  39068.     void *lpData;
  39069.     long flen, mlen;
  39070.     MDxSum mdDataSum;
  39071.     MDxSum md4DataSum;
  39072.  
  39073.     // the 64 is for padding purposes
  39074.     lpData = malloc( READLEN + 64 );
  39075.     
  39076.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39077.  
  39078.     file = fopen( szFName, "rb" );
  39079.     if( file == NULL )
  39080.     {
  39081.         printf("ERROR: File not found.\n");
  39082.         return;
  39083.     }
  39084.     
  39085.     MDxInit( &mdDataSum );
  39086.     MDxInit( &md4DataSum );
  39087.     
  39088.     fseek( file, 0, SEEK_END );
  39089.     //Get the file length
  39090.     flen = mlen = ftell( file );
  39091.     fseek( file, 0, SEEK_SET );
  39092.     
  39093.     // When it takes a while to process a large file,
  39094.     // remember that for each chunk it has to run 
  39095.     // through the main translation loop 16384 times!
  39096.         
  39097.     printf("Processing %ld byte file: .", flen );
  39098.     
  39099.     while( flen > READLEN )
  39100.     {
  39101.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  39102.         {
  39103.             printf("READ ERROR!\n");
  39104.             return;
  39105.         }
  39106.         MD5Translate( lpData, READLEN, &mdDataSum );
  39107.         MD4Translate( lpData, READLEN, &md4DataSum );
  39108.         flen -= READLEN;
  39109.         printf(".");
  39110.     }
  39111.  
  39112.     if (fread( lpData, 1, flen, file ) != flen)
  39113.     {
  39114.         printf("READ ERROR!\n");
  39115.         return;
  39116.     }
  39117.     // This is why I added the new argument to MDxPad
  39118.     // So we can pass the length of the data AND the
  39119.     // Total length of the message
  39120.     // Also it now returns the # of padding bytes added,
  39121.     // this is for files that are an exact multiple of the chunk
  39122.     // length. (Otherwise the padding isn't Translated)
  39123.     flen += MDxPad( lpData, flen, mlen );
  39124.     MD5Translate( lpData, flen, &mdDataSum );    
  39125.     MD4Translate( lpData, flen, &md4DataSum );
  39126.  
  39127.     // New step necessary because of the 'chunking' method
  39128.     MDxFinalize( &mdDataSum );
  39129.     MDxFinalize( &md4DataSum );
  39130.     
  39131.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  39132.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39133.     fclose(file);
  39134.         
  39135. }
  39136.  
  39137. void DigestString()
  39138. {
  39139.     
  39140.     //For our demo purposes, no strings bigger than 1024 :)
  39141.     unsigned char lpData[1024] = "";
  39142.     long len = 0;
  39143.     MDxSum mdDataSum;
  39144.  
  39145.     printf("Enter the string to digest: ");
  39146.     scanf("%s", &lpData );
  39147.     len = strlen(lpData);
  39148.     
  39149.     // Have to do this before the Padding...well...it's best anyway;)
  39150.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  39151.     
  39152.     // For the strings, we're gonna pad and digest the string
  39153.     // in one pass.
  39154.     MDxInit( &mdDataSum );
  39155.     MDxPad( lpData, len, len );
  39156.     
  39157.     MD5Translate( lpData, len, &mdDataSum );
  39158.         // New step necessary because of the 'chunking' method
  39159.         MDxFinalize( &mdDataSum );
  39160.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39161.     
  39162.     MDxInit( &mdDataSum );
  39163.     MD4Translate( lpData, len, &mdDataSum );    
  39164.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39165.  
  39166.     return;
  39167. }
  39168.  
  39169.  
  39170. -------------- Include
  39171.  
  39172. #ifndef __windows_h__
  39173.         typedef unsigned long DWORD;
  39174.         #define STDCALL _stdcall
  39175. #endif
  39176.  
  39177. typedef struct 
  39178. {
  39179.     DWORD dwSum[4];
  39180. }MDxSum;
  39181.  
  39182. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39183. void STDCALL MDxInit( MDxSum * );
  39184. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39185. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39186. const char * STDCALL MDxGetVersion();
  39187. void STDCALL MDxFinalize( MDxSum * );
  39188.  
  39189.  
  39190.  
  39191.  
  39192. #include "mdx.h"
  39193. #include <stdlib.h>
  39194. #include <stdio.h>
  39195. #include <string.h>
  39196.  
  39197. // READLEN % 64 must = 0
  39198. #define READLEN    1048576L // 2^20, 1MB
  39199.  
  39200. void DigestFile( char * );
  39201. void DigestString();
  39202.  
  39203. void main(int argc, char *argv[])
  39204. {
  39205.     printf("%s\n\n", MDxGetVersion());
  39206.  
  39207.     if( argc > 1 )
  39208.         DigestFile( argv[1] );
  39209.     else    
  39210.         DigestString();
  39211.  
  39212. }
  39213.  
  39214. /*
  39215.     I use the 'chunk' method for processing files not because of
  39216.     limitations of my dll, but think what would happen if you
  39217.     tried to load an entire cd image into memory.
  39218. */
  39219. void DigestFile( char *szFName )
  39220. {
  39221.     FILE *file;
  39222.     void *lpData;
  39223.     long flen, mlen;
  39224.     MDxSum mdDataSum;
  39225.     MDxSum md4DataSum;
  39226.  
  39227.     // the 64 is for padding purposes
  39228.     lpData = malloc( READLEN + 64 );
  39229.     
  39230.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39231.  
  39232.     file = fopen( szFName, "rb" );
  39233.     if( file == NULL )
  39234.     {
  39235.         printf("ERROR: File not found.\n");
  39236.         return;
  39237.     }
  39238.     
  39239.     MDxInit( &mdDataSum );
  39240.     MDxInit( &md4DataSum );
  39241.     
  39242.     fseek( file, 0, SEEK_END );
  39243.     //Get the file length
  39244.     flen = mlen = ftell( file );
  39245.     fseek( file, 0, SEEK_SET );
  39246.     
  39247.     // When it takes a while to process a large file,
  39248.     // remember that for each chunk it has to run 
  39249.     // through the main translation loop 16384 times!
  39250.         
  39251.     printf("Processing %ld byte file: .", flen );
  39252.     
  39253.     while( flen > READLEN )
  39254.     {
  39255.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  39256.         {
  39257.             printf("READ ERROR!\n");
  39258.             return;
  39259.         }
  39260.         MD5Translate( lpData, READLEN, &mdDataSum );
  39261.         MD4Translate( lpData, READLEN, &md4DataSum );
  39262.         flen -= READLEN;
  39263.         printf(".");
  39264.     }
  39265.  
  39266.     if (fread( lpData, 1, flen, file ) != flen)
  39267.     {
  39268.         printf("READ ERROR!\n");
  39269.         return;
  39270.     }
  39271.     // This is why I added the new argument to MDxPad
  39272.     // So we can pass the length of the data AND the
  39273.     // Total length of the message
  39274.     // Also it now returns the # of padding bytes added,
  39275.     // this is for files that are an exact multiple of the chunk
  39276.     // length. (Otherwise the padding isn't Translated)
  39277.     flen += MDxPad( lpData, flen, mlen );
  39278.     MD5Translate( lpData, flen, &mdDataSum );    
  39279.     MD4Translate( lpData, flen, &md4DataSum );
  39280.  
  39281.     // New step necessary because of the 'chunking' method
  39282.     MDxFinalize( &mdDataSum );
  39283.     MDxFinalize( &md4DataSum );
  39284.     
  39285.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  39286.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39287.     fclose(file);
  39288.         
  39289. }
  39290.  
  39291. void DigestString()
  39292. {
  39293.     
  39294.     //For our demo purposes, no strings bigger than 1024 :)
  39295.     unsigned char lpData[1024] = "";
  39296.     long len = 0;
  39297.     MDxSum mdDataSum;
  39298.  
  39299.     printf("Enter the string to digest: ");
  39300.     scanf("%s", &lpData );
  39301.     len = strlen(lpData);
  39302.     
  39303.     // Have to do this before the Padding...well...it's best anyway;)
  39304.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  39305.     
  39306.     // For the strings, we're gonna pad and digest the string
  39307.     // in one pass.
  39308.     MDxInit( &mdDataSum );
  39309.     MDxPad( lpData, len, len );
  39310.     
  39311.     MD5Translate( lpData, len, &mdDataSum );
  39312.         // New step necessary because of the 'chunking' method
  39313.         MDxFinalize( &mdDataSum );
  39314.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39315.     
  39316.     MDxInit( &mdDataSum );
  39317.     MD4Translate( lpData, len, &mdDataSum );    
  39318.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39319.  
  39320.     return;
  39321. }
  39322.  
  39323.  
  39324. -------------- Include
  39325.  
  39326. #ifndef __windows_h__
  39327.         typedef unsigned long DWORD;
  39328.         #define STDCALL _stdcall
  39329. #endif
  39330.  
  39331. typedef struct 
  39332. {
  39333.     DWORD dwSum[4];
  39334. }MDxSum;
  39335.  
  39336. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39337. void STDCALL MDxInit( MDxSum * );
  39338. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39339. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39340. const char * STDCALL MDxGetVersion();
  39341. void STDCALL MDxFinalize( MDxSum * );
  39342.  
  39343.  
  39344.  
  39345. #include "mdx.h"
  39346. #include <stdlib.h>
  39347. #include <stdio.h>
  39348. #include <string.h>
  39349.  
  39350. // READLEN % 64 must = 0
  39351. #define READLEN    1048576L // 2^20, 1MB
  39352.  
  39353. void DigestFile( char * );
  39354. void DigestString();
  39355.  
  39356. void main(int argc, char *argv[])
  39357. {
  39358.     printf("%s\n\n", MDxGetVersion());
  39359.  
  39360.     if( argc > 1 )
  39361.         DigestFile( argv[1] );
  39362.     else    
  39363.         DigestString();
  39364.  
  39365. }
  39366.  
  39367. /*
  39368.     I use the 'chunk' method for processing files not because of
  39369.     limitations of my dll, but think what would happen if you
  39370.     tried to load an entire cd image into memory.
  39371. */
  39372. void DigestFile( char *szFName )
  39373. {
  39374.     FILE *file;
  39375.     void *lpData;
  39376.     long flen, mlen;
  39377.     MDxSum mdDataSum;
  39378.     MDxSum md4DataSum;
  39379.  
  39380.     // the 64 is for padding purposes
  39381.     lpData = malloc( READLEN + 64 );
  39382.     
  39383.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39384.  
  39385.     file = fopen( szFName, "rb" );
  39386.     if( file == NULL )
  39387.     {
  39388.         printf("ERROR: File not found.\n");
  39389.         return;
  39390.     }
  39391.     
  39392.     MDxInit( &mdDataSum );
  39393.     MDxInit( &md4DataSum );
  39394.     
  39395.     fseek( file, 0, SEEK_END );
  39396.     //Get the file length
  39397.     flen = mlen = ftell( file );
  39398.     fseek( file, 0, SEEK_SET );
  39399.     
  39400.     // When it takes a while to process a large file,
  39401.     // remember that for each chunk it has to run 
  39402.     // through the main translation loop 16384 times!
  39403.         
  39404.     printf("Processing %ld byte file: .", flen );
  39405.     
  39406.     while( flen > READLEN )
  39407.     {
  39408.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  39409.         {
  39410.             printf("READ ERROR!\n");
  39411.             return;
  39412.         }
  39413.         MD5Translate( lpData, READLEN, &mdDataSum );
  39414.         MD4Translate( lpData, READLEN, &md4DataSum );
  39415.         flen -= READLEN;
  39416.         printf(".");
  39417.     }
  39418.  
  39419.     if (fread( lpData, 1, flen, file ) != flen)
  39420.     {
  39421.         printf("READ ERROR!\n");
  39422.         return;
  39423.     }
  39424.     // This is why I added the new argument to MDxPad
  39425.     // So we can pass the length of the data AND the
  39426.     // Total length of the message
  39427.     // Also it now returns the # of padding bytes added,
  39428.     // this is for files that are an exact multiple of the chunk
  39429.     // length. (Otherwise the padding isn't Translated)
  39430.     flen += MDxPad( lpData, flen, mlen );
  39431.     MD5Translate( lpData, flen, &mdDataSum );    
  39432.     MD4Translate( lpData, flen, &md4DataSum );
  39433.  
  39434.     // New step necessary because of the 'chunking' method
  39435.     MDxFinalize( &mdDataSum );
  39436.     MDxFinalize( &md4DataSum );
  39437.     
  39438.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  39439.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39440.     fclose(file);
  39441.         
  39442. }
  39443.  
  39444. void DigestString()
  39445. {
  39446.     
  39447.     //For our demo purposes, no strings bigger than 1024 :)
  39448.     unsigned char lpData[1024] = "";
  39449.     long len = 0;
  39450.     MDxSum mdDataSum;
  39451.  
  39452.     printf("Enter the string to digest: ");
  39453.     scanf("%s", &lpData );
  39454.     len = strlen(lpData);
  39455.     
  39456.     // Have to do this before the Padding...well...it's best anyway;)
  39457.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  39458.     
  39459.     // For the strings, we're gonna pad and digest the string
  39460.     // in one pass.
  39461.     MDxInit( &mdDataSum );
  39462.     MDxPad( lpData, len, len );
  39463.     
  39464.     MD5Translate( lpData, len, &mdDataSum );
  39465.         // New step necessary because of the 'chunking' method
  39466.         MDxFinalize( &mdDataSum );
  39467.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39468.     
  39469.     MDxInit( &mdDataSum );
  39470.     MD4Translate( lpData, len, &mdDataSum );    
  39471.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39472.  
  39473.     return;
  39474. }
  39475.  
  39476.  
  39477. -------------- Include
  39478.  
  39479. #ifndef __windows_h__
  39480.         typedef unsigned long DWORD;
  39481.         #define STDCALL _stdcall
  39482. #endif
  39483.  
  39484. typedef struct 
  39485. {
  39486.     DWORD dwSum[4];
  39487. }MDxSum;
  39488.  
  39489. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39490. void STDCALL MDxInit( MDxSum * );
  39491. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39492. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39493. const char * STDCALL MDxGetVersion();
  39494. void STDCALL MDxFinalize( MDxSum * );
  39495.  
  39496.  
  39497. #include "mdx.h"
  39498. #include <stdlib.h>
  39499. #include <stdio.h>
  39500. #include <string.h>
  39501.  
  39502. // READLEN % 64 must = 0
  39503. #define READLEN    1048576L // 2^20, 1MB
  39504.  
  39505. void DigestFile( char * );
  39506. void DigestString();
  39507.  
  39508. void main(int argc, char *argv[])
  39509. {
  39510.     printf("%s\n\n", MDxGetVersion());
  39511.  
  39512.     if( argc > 1 )
  39513.         DigestFile( argv[1] );
  39514.     else    
  39515.         DigestString();
  39516.  
  39517. }
  39518.  
  39519. /*
  39520.     I use the 'chunk' method for processing files not because of
  39521.     limitations of my dll, but think what would happen if you
  39522.     tried to load an entire cd image into memory.
  39523. */
  39524. void DigestFile( char *szFName )
  39525. {
  39526.     FILE *file;
  39527.     void *lpData;
  39528.     long flen, mlen;
  39529.     MDxSum mdDataSum;
  39530.     MDxSum md4DataSum;
  39531.  
  39532.     // the 64 is for padding purposes
  39533.     lpData = malloc( READLEN + 64 );
  39534.     
  39535.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39536.  
  39537.     file = fopen( szFName, "rb" );
  39538.     if( file == NULL )
  39539.     {
  39540.         printf("ERROR: File not found.\n");
  39541.         return;
  39542.     }
  39543.     
  39544.     MDxInit( &mdDataSum );
  39545.     MDxInit( &md4DataSum );
  39546.     
  39547.     fseek( file, 0, SEEK_END );
  39548.     //Get the file length
  39549.     flen = mlen = ftell( file );
  39550.     fseek( file, 0, SEEK_SET );
  39551.     
  39552.     // When it takes a while to process a large file,
  39553.     // remember that for each chunk it has to run 
  39554.     // through the main translation loop 16384 times!
  39555.         
  39556.     printf("Processing %ld byte file: .", flen );
  39557.     
  39558.     while( flen > READLEN )
  39559.     {
  39560.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  39561.         {
  39562.             printf("READ ERROR!\n");
  39563.             return;
  39564.         }
  39565.         MD5Translate( lpData, READLEN, &mdDataSum );
  39566.         MD4Translate( lpData, READLEN, &md4DataSum );
  39567.         flen -= READLEN;
  39568.         printf(".");
  39569.     }
  39570.  
  39571.     if (fread( lpData, 1, flen, file ) != flen)
  39572.     {
  39573.         printf("READ ERROR!\n");
  39574.         return;
  39575.     }
  39576.     // This is why I added the new argument to MDxPad
  39577.     // So we can pass the length of the data AND the
  39578.     // Total length of the message
  39579.     // Also it now returns the # of padding bytes added,
  39580.     // this is for files that are an exact multiple of the chunk
  39581.     // length. (Otherwise the padding isn't Translated)
  39582.     flen += MDxPad( lpData, flen, mlen );
  39583.     MD5Translate( lpData, flen, &mdDataSum );    
  39584.     MD4Translate( lpData, flen, &md4DataSum );
  39585.  
  39586.     // New step necessary because of the 'chunking' method
  39587.     MDxFinalize( &mdDataSum );
  39588.     MDxFinalize( &md4DataSum );
  39589.     
  39590.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  39591.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39592.     fclose(file);
  39593.         
  39594. }
  39595.  
  39596. void DigestString()
  39597. {
  39598.     
  39599.     //For our demo purposes, no strings bigger than 1024 :)
  39600.     unsigned char lpData[1024] = "";
  39601.     long len = 0;
  39602.     MDxSum mdDataSum;
  39603.  
  39604.     printf("Enter the string to digest: ");
  39605.     scanf("%s", &lpData );
  39606.     len = strlen(lpData);
  39607.     
  39608.     // Have to do this before the Padding...well...it's best anyway;)
  39609.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  39610.     
  39611.     // For the strings, we're gonna pad and digest the string
  39612.     // in one pass.
  39613.     MDxInit( &mdDataSum );
  39614.     MDxPad( lpData, len, len );
  39615.     
  39616.     MD5Translate( lpData, len, &mdDataSum );
  39617.         // New step necessary because of the 'chunking' method
  39618.         MDxFinalize( &mdDataSum );
  39619.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39620.     
  39621.     MDxInit( &mdDataSum );
  39622.     MD4Translate( lpData, len, &mdDataSum );    
  39623.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39624.  
  39625.     return;
  39626. }
  39627.  
  39628.  
  39629. -------------- Include
  39630.  
  39631. #ifndef __windows_h__
  39632.         typedef unsigned long DWORD;
  39633.         #define STDCALL _stdcall
  39634. #endif
  39635.  
  39636. typedef struct 
  39637. {
  39638.     DWORD dwSum[4];
  39639. }MDxSum;
  39640.  
  39641. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39642. void STDCALL MDxInit( MDxSum * );
  39643. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39644. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39645. const char * STDCALL MDxGetVersion();
  39646. void STDCALL MDxFinalize( MDxSum * );
  39647.  
  39648.  
  39649.  
  39650. #include "mdx.h"
  39651. #include <stdlib.h>
  39652. #include <stdio.h>
  39653. #include <string.h>
  39654.  
  39655. // READLEN % 64 must = 0
  39656. #define READLEN    1048576L // 2^20, 1MB
  39657.  
  39658. void DigestFile( char * );
  39659. void DigestString();
  39660.  
  39661. void main(int argc, char *argv[])
  39662. {
  39663.     printf("%s\n\n", MDxGetVersion());
  39664.  
  39665.     if( argc > 1 )
  39666.         DigestFile( argv[1] );
  39667.     else    
  39668.         DigestString();
  39669.  
  39670. }
  39671.  
  39672. /*
  39673.     I use the 'chunk' method for processing files not because of
  39674.     limitations of my dll, but think what would happen if you
  39675.     tried to load an entire cd image into memory.
  39676. */
  39677. void DigestFile( char *szFName )
  39678. {
  39679.     FILE *file;
  39680.     void *lpData;
  39681.     long flen, mlen;
  39682.     MDxSum mdDataSum;
  39683.     MDxSum md4DataSum;
  39684.  
  39685.     // the 64 is for padding purposes
  39686.     lpData = malloc( READLEN + 64 );
  39687.     
  39688.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39689.  
  39690.     file = fopen( szFName, "rb" );
  39691.     if( file == NULL )
  39692.     {
  39693.         printf("ERROR: File not found.\n");
  39694.         return;
  39695.     }
  39696.     
  39697.     MDxInit( &mdDataSum );
  39698.     MDxInit( &md4DataSum );
  39699.     
  39700.     fseek( file, 0, SEEK_END );
  39701.     //Get the file length
  39702.     flen = mlen = ftell( file );
  39703.     fseek( file, 0, SEEK_SET );
  39704.     
  39705.     // When it takes a while to process a large file,
  39706.     // remember that for each chunk it has to run 
  39707.     // through the main translation loop 16384 times!
  39708.         
  39709.     printf("Processing %ld byte file: .", flen );
  39710.     
  39711.     while( flen > READLEN )
  39712.     {
  39713.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  39714.         {
  39715.             printf("READ ERROR!\n");
  39716.             return;
  39717.         }
  39718.         MD5Translate( lpData, READLEN, &mdDataSum );
  39719.         MD4Translate( lpData, READLEN, &md4DataSum );
  39720.         flen -= READLEN;
  39721.         printf(".");
  39722.     }
  39723.  
  39724.     if (fread( lpData, 1, flen, file ) != flen)
  39725.     {
  39726.         printf("READ ERROR!\n");
  39727.         return;
  39728.     }
  39729.     // This is why I added the new argument to MDxPad
  39730.     // So we can pass the length of the data AND the
  39731.     // Total length of the message
  39732.     // Also it now returns the # of padding bytes added,
  39733.     // this is for files that are an exact multiple of the chunk
  39734.     // length. (Otherwise the padding isn't Translated)
  39735.     flen += MDxPad( lpData, flen, mlen );
  39736.     MD5Translate( lpData, flen, &mdDataSum );    
  39737.     MD4Translate( lpData, flen, &md4DataSum );
  39738.  
  39739.     // New step necessary because of the 'chunking' method
  39740.     MDxFinalize( &mdDataSum );
  39741.     MDxFinalize( &md4DataSum );
  39742.     
  39743.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  39744.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39745.     fclose(file);
  39746.         
  39747. }
  39748.  
  39749. void DigestString()
  39750. {
  39751.     
  39752.     //For our demo purposes, no strings bigger than 1024 :)
  39753.     unsigned char lpData[1024] = "";
  39754.     long len = 0;
  39755.     MDxSum mdDataSum;
  39756.  
  39757.     printf("Enter the string to digest: ");
  39758.     scanf("%s", &lpData );
  39759.     len = strlen(lpData);
  39760.     
  39761.     // Have to do this before the Padding...well...it's best anyway;)
  39762.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  39763.     
  39764.     // For the strings, we're gonna pad and digest the string
  39765.     // in one pass.
  39766.     MDxInit( &mdDataSum );
  39767.     MDxPad( lpData, len, len );
  39768.     
  39769.     MD5Translate( lpData, len, &mdDataSum );
  39770.         // New step necessary because of the 'chunking' method
  39771.         MDxFinalize( &mdDataSum );
  39772.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39773.     
  39774.     MDxInit( &mdDataSum );
  39775.     MD4Translate( lpData, len, &mdDataSum );    
  39776.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39777.  
  39778.     return;
  39779. }
  39780.  
  39781.  
  39782. -------------- Include
  39783.  
  39784. #ifndef __windows_h__
  39785.         typedef unsigned long DWORD;
  39786.         #define STDCALL _stdcall
  39787. #endif
  39788.  
  39789. typedef struct 
  39790. {
  39791.     DWORD dwSum[4];
  39792. }MDxSum;
  39793.  
  39794. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39795. void STDCALL MDxInit( MDxSum * );
  39796. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39797. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39798. const char * STDCALL MDxGetVersion();
  39799. void STDCALL MDxFinalize( MDxSum * );
  39800.  
  39801.  
  39802.  
  39803. #include "mdx.h"
  39804. #include <stdlib.h>
  39805. #include <stdio.h>
  39806. #include <string.h>
  39807.  
  39808. // READLEN % 64 must = 0
  39809. #define READLEN    1048576L // 2^20, 1MB
  39810.  
  39811. void DigestFile( char * );
  39812. void DigestString();
  39813.  
  39814. void main(int argc, char *argv[])
  39815. {
  39816.     printf("%s\n\n", MDxGetVersion());
  39817.  
  39818.     if( argc > 1 )
  39819.         DigestFile( argv[1] );
  39820.     else    
  39821.         DigestString();
  39822.  
  39823. }
  39824.  
  39825. /*
  39826.     I use the 'chunk' method for processing files not because of
  39827.     limitations of my dll, but think what would happen if you
  39828.     tried to load an entire cd image into memory.
  39829. */
  39830. void DigestFile( char *szFName )
  39831. {
  39832.     FILE *file;
  39833.     void *lpData;
  39834.     long flen, mlen;
  39835.     MDxSum mdDataSum;
  39836.     MDxSum md4DataSum;
  39837.  
  39838.     // the 64 is for padding purposes
  39839.     lpData = malloc( READLEN + 64 );
  39840.     
  39841.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39842.  
  39843.     file = fopen( szFName, "rb" );
  39844.     if( file == NULL )
  39845.     {
  39846.         printf("ERROR: File not found.\n");
  39847.         return;
  39848.     }
  39849.     
  39850.     MDxInit( &mdDataSum );
  39851.     MDxInit( &md4DataSum );
  39852.     
  39853.     fseek( file, 0, SEEK_END );
  39854.     //Get the file length
  39855.     flen = mlen = ftell( file );
  39856.     fseek( file, 0, SEEK_SET );
  39857.     
  39858.     // When it takes a while to process a large file,
  39859.     // remember that for each chunk it has to run 
  39860.     // through the main translation loop 16384 times!
  39861.         
  39862.     printf("Processing %ld byte file: .", flen );
  39863.     
  39864.     while( flen > READLEN )
  39865.     {
  39866.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  39867.         {
  39868.             printf("READ ERROR!\n");
  39869.             return;
  39870.         }
  39871.         MD5Translate( lpData, READLEN, &mdDataSum );
  39872.         MD4Translate( lpData, READLEN, &md4DataSum );
  39873.         flen -= READLEN;
  39874.         printf(".");
  39875.     }
  39876.  
  39877.     if (fread( lpData, 1, flen, file ) != flen)
  39878.     {
  39879.         printf("READ ERROR!\n");
  39880.         return;
  39881.     }
  39882.     // This is why I added the new argument to MDxPad
  39883.     // So we can pass the length of the data AND the
  39884.     // Total length of the message
  39885.     // Also it now returns the # of padding bytes added,
  39886.     // this is for files that are an exact multiple of the chunk
  39887.     // length. (Otherwise the padding isn't Translated)
  39888.     flen += MDxPad( lpData, flen, mlen );
  39889.     MD5Translate( lpData, flen, &mdDataSum );    
  39890.     MD4Translate( lpData, flen, &md4DataSum );
  39891.  
  39892.     // New step necessary because of the 'chunking' method
  39893.     MDxFinalize( &mdDataSum );
  39894.     MDxFinalize( &md4DataSum );
  39895.     
  39896.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  39897.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39898.     fclose(file);
  39899.         
  39900. }
  39901.  
  39902. void DigestString()
  39903. {
  39904.     
  39905.     //For our demo purposes, no strings bigger than 1024 :)
  39906.     unsigned char lpData[1024] = "";
  39907.     long len = 0;
  39908.     MDxSum mdDataSum;
  39909.  
  39910.     printf("Enter the string to digest: ");
  39911.     scanf("%s", &lpData );
  39912.     len = strlen(lpData);
  39913.     
  39914.     // Have to do this before the Padding...well...it's best anyway;)
  39915.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  39916.     
  39917.     // For the strings, we're gonna pad and digest the string
  39918.     // in one pass.
  39919.     MDxInit( &mdDataSum );
  39920.     MDxPad( lpData, len, len );
  39921.     
  39922.     MD5Translate( lpData, len, &mdDataSum );
  39923.         // New step necessary because of the 'chunking' method
  39924.         MDxFinalize( &mdDataSum );
  39925.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39926.     
  39927.     MDxInit( &mdDataSum );
  39928.     MD4Translate( lpData, len, &mdDataSum );    
  39929.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  39930.  
  39931.     return;
  39932. }
  39933.  
  39934.  
  39935. -------------- Include
  39936.  
  39937. #ifndef __windows_h__
  39938.         typedef unsigned long DWORD;
  39939.         #define STDCALL _stdcall
  39940. #endif
  39941.  
  39942. typedef struct 
  39943. {
  39944.     DWORD dwSum[4];
  39945. }MDxSum;
  39946.  
  39947. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  39948. void STDCALL MDxInit( MDxSum * );
  39949. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  39950. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  39951. const char * STDCALL MDxGetVersion();
  39952. void STDCALL MDxFinalize( MDxSum * );
  39953.  
  39954.  
  39955. #include "mdx.h"
  39956. #include <stdlib.h>
  39957. #include <stdio.h>
  39958. #include <string.h>
  39959.  
  39960. // READLEN % 64 must = 0
  39961. #define READLEN    1048576L // 2^20, 1MB
  39962.  
  39963. void DigestFile( char * );
  39964. void DigestString();
  39965.  
  39966. void main(int argc, char *argv[])
  39967. {
  39968.     printf("%s\n\n", MDxGetVersion());
  39969.  
  39970.     if( argc > 1 )
  39971.         DigestFile( argv[1] );
  39972.     else    
  39973.         DigestString();
  39974.  
  39975. }
  39976.  
  39977. /*
  39978.     I use the 'chunk' method for processing files not because of
  39979.     limitations of my dll, but think what would happen if you
  39980.     tried to load an entire cd image into memory.
  39981. */
  39982. void DigestFile( char *szFName )
  39983. {
  39984.     FILE *file;
  39985.     void *lpData;
  39986.     long flen, mlen;
  39987.     MDxSum mdDataSum;
  39988.     MDxSum md4DataSum;
  39989.  
  39990.     // the 64 is for padding purposes
  39991.     lpData = malloc( READLEN + 64 );
  39992.     
  39993.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  39994.  
  39995.     file = fopen( szFName, "rb" );
  39996.     if( file == NULL )
  39997.     {
  39998.         printf("ERROR: File not found.\n");
  39999.         return;
  40000.     }
  40001.     
  40002.     MDxInit( &mdDataSum );
  40003.     MDxInit( &md4DataSum );
  40004.     
  40005.     fseek( file, 0, SEEK_END );
  40006.     //Get the file length
  40007.     flen = mlen = ftell( file );
  40008.     fseek( file, 0, SEEK_SET );
  40009.     
  40010.     // When it takes a while to process a large file,
  40011.     // remember that for each chunk it has to run 
  40012.     // through the main translation loop 16384 times!
  40013.         
  40014.     printf("Processing %ld byte file: .", flen );
  40015.     
  40016.     while( flen > READLEN )
  40017.     {
  40018.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40019.         {
  40020.             printf("READ ERROR!\n");
  40021.             return;
  40022.         }
  40023.         MD5Translate( lpData, READLEN, &mdDataSum );
  40024.         MD4Translate( lpData, READLEN, &md4DataSum );
  40025.         flen -= READLEN;
  40026.         printf(".");
  40027.     }
  40028.  
  40029.     if (fread( lpData, 1, flen, file ) != flen)
  40030.     {
  40031.         printf("READ ERROR!\n");
  40032.         return;
  40033.     }
  40034.     // This is why I added the new argument to MDxPad
  40035.     // So we can pass the length of the data AND the
  40036.     // Total length of the message
  40037.     // Also it now returns the # of padding bytes added,
  40038.     // this is for files that are an exact multiple of the chunk
  40039.     // length. (Otherwise the padding isn't Translated)
  40040.     flen += MDxPad( lpData, flen, mlen );
  40041.     MD5Translate( lpData, flen, &mdDataSum );    
  40042.     MD4Translate( lpData, flen, &md4DataSum );
  40043.  
  40044.     // New step necessary because of the 'chunking' method
  40045.     MDxFinalize( &mdDataSum );
  40046.     MDxFinalize( &md4DataSum );
  40047.     
  40048.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40049.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40050.     fclose(file);
  40051.         
  40052. }
  40053.  
  40054. void DigestString()
  40055. {
  40056.     
  40057.     //For our demo purposes, no strings bigger than 1024 :)
  40058.     unsigned char lpData[1024] = "";
  40059.     long len = 0;
  40060.     MDxSum mdDataSum;
  40061.  
  40062.     printf("Enter the string to digest: ");
  40063.     scanf("%s", &lpData );
  40064.     len = strlen(lpData);
  40065.     
  40066.     // Have to do this before the Padding...well...it's best anyway;)
  40067.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40068.     
  40069.     // For the strings, we're gonna pad and digest the string
  40070.     // in one pass.
  40071.     MDxInit( &mdDataSum );
  40072.     MDxPad( lpData, len, len );
  40073.     
  40074.     MD5Translate( lpData, len, &mdDataSum );
  40075.         // New step necessary because of the 'chunking' method
  40076.         MDxFinalize( &mdDataSum );
  40077.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40078.     
  40079.     MDxInit( &mdDataSum );
  40080.     MD4Translate( lpData, len, &mdDataSum );    
  40081.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40082.  
  40083.     return;
  40084. }
  40085.  
  40086.  
  40087. -------------- Include
  40088.  
  40089. #ifndef __windows_h__
  40090.         typedef unsigned long DWORD;
  40091.         #define STDCALL _stdcall
  40092. #endif
  40093.  
  40094. typedef struct 
  40095. {
  40096.     DWORD dwSum[4];
  40097. }MDxSum;
  40098.  
  40099. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  40100. void STDCALL MDxInit( MDxSum * );
  40101. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  40102. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  40103. const char * STDCALL MDxGetVersion();
  40104. void STDCALL MDxFinalize( MDxSum * );
  40105.  
  40106.  
  40107. #include "mdx.h"
  40108. #include <stdlib.h>
  40109. #include <stdio.h>
  40110. #include <string.h>
  40111.  
  40112. // READLEN % 64 must = 0
  40113. #define READLEN    1048576L // 2^20, 1MB
  40114.  
  40115. void DigestFile( char * );
  40116. void DigestString();
  40117.  
  40118. void main(int argc, char *argv[])
  40119. {
  40120.     printf("%s\n\n", MDxGetVersion());
  40121.  
  40122.     if( argc > 1 )
  40123.         DigestFile( argv[1] );
  40124.     else    
  40125.         DigestString();
  40126.  
  40127. }
  40128.  
  40129. /*
  40130.     I use the 'chunk' method for processing files not because of
  40131.     limitations of my dll, but think what would happen if you
  40132.     tried to load an entire cd image into memory.
  40133. */
  40134. void DigestFile( char *szFName )
  40135. {
  40136.     FILE *file;
  40137.     void *lpData;
  40138.     long flen, mlen;
  40139.     MDxSum mdDataSum;
  40140.     MDxSum md4DataSum;
  40141.  
  40142.     // the 64 is for padding purposes
  40143.     lpData = malloc( READLEN + 64 );
  40144.     
  40145.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40146.  
  40147.     file = fopen( szFName, "rb" );
  40148.     if( file == NULL )
  40149.     {
  40150.         printf("ERROR: File not found.\n");
  40151.         return;
  40152.     }
  40153.     
  40154.     MDxInit( &mdDataSum );
  40155.     MDxInit( &md4DataSum );
  40156.     
  40157.     fseek( file, 0, SEEK_END );
  40158.     //Get the file length
  40159.     flen = mlen = ftell( file );
  40160.     fseek( file, 0, SEEK_SET );
  40161.     
  40162.     // When it takes a while to process a large file,
  40163.     // remember that for each chunk it has to run 
  40164.     // through the main translation loop 16384 times!
  40165.         
  40166.     printf("Processing %ld byte file: .", flen );
  40167.     
  40168.     while( flen > READLEN )
  40169.     {
  40170.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40171.         {
  40172.             printf("READ ERROR!\n");
  40173.             return;
  40174.         }
  40175.         MD5Translate( lpData, READLEN, &mdDataSum );
  40176.         MD4Translate( lpData, READLEN, &md4DataSum );
  40177.         flen -= READLEN;
  40178.         printf(".");
  40179.     }
  40180.  
  40181.     if (fread( lpData, 1, flen, file ) != flen)
  40182.     {
  40183.         printf("READ ERROR!\n");
  40184.         return;
  40185.     }
  40186.     // This is why I added the new argument to MDxPad
  40187.     // So we can pass the length of the data AND the
  40188.     // Total length of the message
  40189.     // Also it now returns the # of padding bytes added,
  40190.     // this is for files that are an exact multiple of the chunk
  40191.     // length. (Otherwise the padding isn't Translated)
  40192.     flen += MDxPad( lpData, flen, mlen );
  40193.     MD5Translate( lpData, flen, &mdDataSum );    
  40194.     MD4Translate( lpData, flen, &md4DataSum );
  40195.  
  40196.     // New step necessary because of the 'chunking' method
  40197.     MDxFinalize( &mdDataSum );
  40198.     MDxFinalize( &md4DataSum );
  40199.     
  40200.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40201.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40202.     fclose(file);
  40203.         
  40204. }
  40205.  
  40206. void DigestString()
  40207. {
  40208.     
  40209.     //For our demo purposes, no strings bigger than 1024 :)
  40210.     unsigned char lpData[1024] = "";
  40211.     long len = 0;
  40212.     MDxSum mdDataSum;
  40213.  
  40214.     printf("Enter the string to digest: ");
  40215.     scanf("%s", &lpData );
  40216.     len = strlen(lpData);
  40217.     
  40218.     // Have to do this before the Padding...well...it's best anyway;)
  40219.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40220.     
  40221.     // For the strings, we're gonna pad and digest the string
  40222.     // in one pass.
  40223.     MDxInit( &mdDataSum );
  40224.     MDxPad( lpData, len, len );
  40225.     
  40226.     MD5Translate( lpData, len, &mdDataSum );
  40227.         // New step necessary because of the 'chunking' method
  40228.         MDxFinalize( &mdDataSum );
  40229.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40230.     
  40231.     MDxInit( &mdDataSum );
  40232.     MD4Translate( lpData, len, &mdDataSum );    
  40233.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40234.  
  40235.     return;
  40236. }
  40237.  
  40238.  
  40239. -------------- Include
  40240.  
  40241. #ifndef __windows_h__
  40242.         typedef unsigned long DWORD;
  40243.         #define STDCALL _stdcall
  40244. #endif
  40245.  
  40246. typedef struct 
  40247. {
  40248.     DWORD dwSum[4];
  40249. }MDxSum;
  40250.  
  40251. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  40252. void STDCALL MDxInit( MDxSum * );
  40253. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  40254. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  40255. const char * STDCALL MDxGetVersion();
  40256. void STDCALL MDxFinalize( MDxSum * );
  40257.  
  40258.  
  40259.  
  40260. #include "mdx.h"
  40261. #include <stdlib.h>
  40262. #include <stdio.h>
  40263. #include <string.h>
  40264.  
  40265. // READLEN % 64 must = 0
  40266. #define READLEN    1048576L // 2^20, 1MB
  40267.  
  40268. void DigestFile( char * );
  40269. void DigestString();
  40270.  
  40271. void main(int argc, char *argv[])
  40272. {
  40273.     printf("%s\n\n", MDxGetVersion());
  40274.  
  40275.     if( argc > 1 )
  40276.         DigestFile( argv[1] );
  40277.     else    
  40278.         DigestString();
  40279.  
  40280. }
  40281.  
  40282. /*
  40283.     I use the 'chunk' method for processing files not because of
  40284.     limitations of my dll, but think what would happen if you
  40285.     tried to load an entire cd image into memory.
  40286. */
  40287. void DigestFile( char *szFName )
  40288. {
  40289.     FILE *file;
  40290.     void *lpData;
  40291.     long flen, mlen;
  40292.     MDxSum mdDataSum;
  40293.     MDxSum md4DataSum;
  40294.  
  40295.     // the 64 is for padding purposes
  40296.     lpData = malloc( READLEN + 64 );
  40297.     
  40298.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40299.  
  40300.     file = fopen( szFName, "rb" );
  40301.     if( file == NULL )
  40302.     {
  40303.         printf("ERROR: File not found.\n");
  40304.         return;
  40305.     }
  40306.     
  40307.     MDxInit( &mdDataSum );
  40308.     MDxInit( &md4DataSum );
  40309.     
  40310.     fseek( file, 0, SEEK_END );
  40311.     //Get the file length
  40312.     flen = mlen = ftell( file );
  40313.     fseek( file, 0, SEEK_SET );
  40314.     
  40315.     // When it takes a while to process a large file,
  40316.     // remember that for each chunk it has to run 
  40317.     // through the main translation loop 16384 times!
  40318.         
  40319.     printf("Processing %ld byte file: .", flen );
  40320.     
  40321.     while( flen > READLEN )
  40322.     {
  40323.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40324.         {
  40325.             printf("READ ERROR!\n");
  40326.             return;
  40327.         }
  40328.         MD5Translate( lpData, READLEN, &mdDataSum );
  40329.         MD4Translate( lpData, READLEN, &md4DataSum );
  40330.         flen -= READLEN;
  40331.         printf(".");
  40332.     }
  40333.  
  40334.     if (fread( lpData, 1, flen, file ) != flen)
  40335.     {
  40336.         printf("READ ERROR!\n");
  40337.         return;
  40338.     }
  40339.     // This is why I added the new argument to MDxPad
  40340.     // So we can pass the length of the data AND the
  40341.     // Total length of the message
  40342.     // Also it now returns the # of padding bytes added,
  40343.     // this is for files that are an exact multiple of the chunk
  40344.     // length. (Otherwise the padding isn't Translated)
  40345.     flen += MDxPad( lpData, flen, mlen );
  40346.     MD5Translate( lpData, flen, &mdDataSum );    
  40347.     MD4Translate( lpData, flen, &md4DataSum );
  40348.  
  40349.     // New step necessary because of the 'chunking' method
  40350.     MDxFinalize( &mdDataSum );
  40351.     MDxFinalize( &md4DataSum );
  40352.     
  40353.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40354.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40355.     fclose(file);
  40356.         
  40357. }
  40358.  
  40359. void DigestString()
  40360. {
  40361.     
  40362.     //For our demo purposes, no strings bigger than 1024 :)
  40363.     unsigned char lpData[1024] = "";
  40364.     long len = 0;
  40365.     MDxSum mdDataSum;
  40366.  
  40367.     printf("Enter the string to digest: ");
  40368.     scanf("%s", &lpData );
  40369.     len = strlen(lpData);
  40370.     
  40371.     // Have to do this before the Padding...well...it's best anyway;)
  40372.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40373.     
  40374.     // For the strings, we're gonna pad and digest the string
  40375.     // in one pass.
  40376.     MDxInit( &mdDataSum );
  40377.     MDxPad( lpData, len, len );
  40378.     
  40379.     MD5Translate( lpData, len, &mdDataSum );
  40380.         // New step necessary because of the 'chunking' method
  40381.         MDxFinalize( &mdDataSum );
  40382.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40383.     
  40384.     MDxInit( &mdDataSum );
  40385.     MD4Translate( lpData, len, &mdDataSum );    
  40386.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40387.  
  40388.     return;
  40389. }
  40390.  
  40391.  
  40392. -------------- Include
  40393.  
  40394. #ifndef __windows_h__
  40395.         typedef unsigned long DWORD;
  40396.         #define STDCALL _stdcall
  40397. #endif
  40398.  
  40399. typedef struct 
  40400. {
  40401.     DWORD dwSum[4];
  40402. }MDxSum;
  40403.  
  40404. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  40405. void STDCALL MDxInit( MDxSum * );
  40406. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  40407. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  40408. const char * STDCALL MDxGetVersion();
  40409. void STDCALL MDxFinalize( MDxSum * );
  40410.  
  40411.  
  40412.  
  40413. #include "mdx.h"
  40414. #include <stdlib.h>
  40415. #include <stdio.h>
  40416. #include <string.h>
  40417.  
  40418. // READLEN % 64 must = 0
  40419. #define READLEN    1048576L // 2^20, 1MB
  40420.  
  40421. void DigestFile( char * );
  40422. void DigestString();
  40423.  
  40424. void main(int argc, char *argv[])
  40425. {
  40426.     printf("%s\n\n", MDxGetVersion());
  40427.  
  40428.     if( argc > 1 )
  40429.         DigestFile( argv[1] );
  40430.     else    
  40431.         DigestString();
  40432.  
  40433. }
  40434.  
  40435. /*
  40436.     I use the 'chunk' method for processing files not because of
  40437.     limitations of my dll, but think what would happen if you
  40438.     tried to load an entire cd image into memory.
  40439. */
  40440. void DigestFile( char *szFName )
  40441. {
  40442.     FILE *file;
  40443.     void *lpData;
  40444.     long flen, mlen;
  40445.     MDxSum mdDataSum;
  40446.     MDxSum md4DataSum;
  40447.  
  40448.     // the 64 is for padding purposes
  40449.     lpData = malloc( READLEN + 64 );
  40450.     
  40451.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40452.  
  40453.     file = fopen( szFName, "rb" );
  40454.     if( file == NULL )
  40455.     {
  40456.         printf("ERROR: File not found.\n");
  40457.         return;
  40458.     }
  40459.     
  40460.     MDxInit( &mdDataSum );
  40461.     MDxInit( &md4DataSum );
  40462.     
  40463.     fseek( file, 0, SEEK_END );
  40464.     //Get the file length
  40465.     flen = mlen = ftell( file );
  40466.     fseek( file, 0, SEEK_SET );
  40467.     
  40468.     // When it takes a while to process a large file,
  40469.     // remember that for each chunk it has to run 
  40470.     // through the main translation loop 16384 times!
  40471.         
  40472.     printf("Processing %ld byte file: .", flen );
  40473.     
  40474.     while( flen > READLEN )
  40475.     {
  40476.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40477.         {
  40478.             printf("READ ERROR!\n");
  40479.             return;
  40480.         }
  40481.         MD5Translate( lpData, READLEN, &mdDataSum );
  40482.         MD4Translate( lpData, READLEN, &md4DataSum );
  40483.         flen -= READLEN;
  40484.         printf(".");
  40485.     }
  40486.  
  40487.     if (fread( lpData, 1, flen, file ) != flen)
  40488.     {
  40489.         printf("READ ERROR!\n");
  40490.         return;
  40491.     }
  40492.     // This is why I added the new argument to MDxPad
  40493.     // So we can pass the length of the data AND the
  40494.     // Total length of the message
  40495.     // Also it now returns the # of padding bytes added,
  40496.     // this is for files that are an exact multiple of the chunk
  40497.     // length. (Otherwise the padding isn't Translated)
  40498.     flen += MDxPad( lpData, flen, mlen );
  40499.     MD5Translate( lpData, flen, &mdDataSum );    
  40500.     MD4Translate( lpData, flen, &md4DataSum );
  40501.  
  40502.     // New step necessary because of the 'chunking' method
  40503.     MDxFinalize( &mdDataSum );
  40504.     MDxFinalize( &md4DataSum );
  40505.     
  40506.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40507.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40508.     fclose(file);
  40509.         
  40510. }
  40511.  
  40512. void DigestString()
  40513. {
  40514.     
  40515.     //For our demo purposes, no strings bigger than 1024 :)
  40516.     unsigned char lpData[1024] = "";
  40517.     long len = 0;
  40518.     MDxSum mdDataSum;
  40519.  
  40520.     printf("Enter the string to digest: ");
  40521.     scanf("%s", &lpData );
  40522.     len = strlen(lpData);
  40523.     
  40524.     // Have to do this before the Padding...well...it's best anyway;)
  40525.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40526.     
  40527.     // For the strings, we're gonna pad and digest the string
  40528.     // in one pass.
  40529.     MDxInit( &mdDataSum );
  40530.     MDxPad( lpData, len, len );
  40531.     
  40532.     MD5Translate( lpData, len, &mdDataSum );
  40533.         // New step necessary because of the 'chunking' method
  40534.         MDxFinalize( &mdDataSum );
  40535.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40536.     
  40537.     MDxInit( &mdDataSum );
  40538.     MD4Translate( lpData, len, &mdDataSum );    
  40539.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40540.  
  40541.     return;
  40542. }
  40543.  
  40544.  
  40545. -------------- Include
  40546.  
  40547. #ifndef __windows_h__
  40548.         typedef unsigned long DWORD;
  40549.         #define STDCALL _stdcall
  40550. #endif
  40551.  
  40552. typedef struct 
  40553. {
  40554.     DWORD dwSum[4];
  40555. }MDxSum;
  40556.  
  40557. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  40558. void STDCALL MDxInit( MDxSum * );
  40559. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  40560. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  40561. const char * STDCALL MDxGetVersion();
  40562. void STDCALL MDxFinalize( MDxSum * );
  40563.  
  40564.  
  40565.  
  40566. #include "mdx.h"
  40567. #include <stdlib.h>
  40568. #include <stdio.h>
  40569. #include <string.h>
  40570.  
  40571. // READLEN % 64 must = 0
  40572. #define READLEN    1048576L // 2^20, 1MB
  40573.  
  40574. void DigestFile( char * );
  40575. void DigestString();
  40576.  
  40577. void main(int argc, char *argv[])
  40578. {
  40579.     printf("%s\n\n", MDxGetVersion());
  40580.  
  40581.     if( argc > 1 )
  40582.         DigestFile( argv[1] );
  40583.     else    
  40584.         DigestString();
  40585.  
  40586. }
  40587.  
  40588. /*
  40589.     I use the 'chunk' method for processing files not because of
  40590.     limitations of my dll, but think what would happen if you
  40591.     tried to load an entire cd image into memory.
  40592. */
  40593. void DigestFile( char *szFName )
  40594. {
  40595.     FILE *file;
  40596.     void *lpData;
  40597.     long flen, mlen;
  40598.     MDxSum mdDataSum;
  40599.     MDxSum md4DataSum;
  40600.  
  40601.     // the 64 is for padding purposes
  40602.     lpData = malloc( READLEN + 64 );
  40603.     
  40604.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40605.  
  40606.     file = fopen( szFName, "rb" );
  40607.     if( file == NULL )
  40608.     {
  40609.         printf("ERROR: File not found.\n");
  40610.         return;
  40611.     }
  40612.     
  40613.     MDxInit( &mdDataSum );
  40614.     MDxInit( &md4DataSum );
  40615.     
  40616.     fseek( file, 0, SEEK_END );
  40617.     //Get the file length
  40618.     flen = mlen = ftell( file );
  40619.     fseek( file, 0, SEEK_SET );
  40620.     
  40621.     // When it takes a while to process a large file,
  40622.     // remember that for each chunk it has to run 
  40623.     // through the main translation loop 16384 times!
  40624.         
  40625.     printf("Processing %ld byte file: .", flen );
  40626.     
  40627.     while( flen > READLEN )
  40628.     {
  40629.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40630.         {
  40631.             printf("READ ERROR!\n");
  40632.             return;
  40633.         }
  40634.         MD5Translate( lpData, READLEN, &mdDataSum );
  40635.         MD4Translate( lpData, READLEN, &md4DataSum );
  40636.         flen -= READLEN;
  40637.         printf(".");
  40638.     }
  40639.  
  40640.     if (fread( lpData, 1, flen, file ) != flen)
  40641.     {
  40642.         printf("READ ERROR!\n");
  40643.         return;
  40644.     }
  40645.     // This is why I added the new argument to MDxPad
  40646.     // So we can pass the length of the data AND the
  40647.     // Total length of the message
  40648.     // Also it now returns the # of padding bytes added,
  40649.     // this is for files that are an exact multiple of the chunk
  40650.     // length. (Otherwise the padding isn't Translated)
  40651.     flen += MDxPad( lpData, flen, mlen );
  40652.     MD5Translate( lpData, flen, &mdDataSum );    
  40653.     MD4Translate( lpData, flen, &md4DataSum );
  40654.  
  40655.     // New step necessary because of the 'chunking' method
  40656.     MDxFinalize( &mdDataSum );
  40657.     MDxFinalize( &md4DataSum );
  40658.     
  40659.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40660.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40661.     fclose(file);
  40662.         
  40663. }
  40664.  
  40665. void DigestString()
  40666. {
  40667.     
  40668.     //For our demo purposes, no strings bigger than 1024 :)
  40669.     unsigned char lpData[1024] = "";
  40670.     long len = 0;
  40671.     MDxSum mdDataSum;
  40672.  
  40673.     printf("Enter the string to digest: ");
  40674.     scanf("%s", &lpData );
  40675.     len = strlen(lpData);
  40676.     
  40677.     // Have to do this before the Padding...well...it's best anyway;)
  40678.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40679.     
  40680.     // For the strings, we're gonna pad and digest the string
  40681.     // in one pass.
  40682.     MDxInit( &mdDataSum );
  40683.     MDxPad( lpData, len, len );
  40684.     
  40685.     MD5Translate( lpData, len, &mdDataSum );
  40686.         // New step necessary because of the 'chunking' method
  40687.         MDxFinalize( &mdDataSum );
  40688.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40689.     
  40690.     MDxInit( &mdDataSum );
  40691.     MD4Translate( lpData, len, &mdDataSum );    
  40692.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40693.  
  40694.     return;
  40695. }
  40696.  
  40697.  
  40698. -------------- Include
  40699.  
  40700. #ifndef __windows_h__
  40701.         typedef unsigned long DWORD;
  40702.         #define STDCALL _stdcall
  40703. #endif
  40704.  
  40705. typedef struct 
  40706. {
  40707.     DWORD dwSum[4];
  40708. }MDxSum;
  40709.  
  40710. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  40711. void STDCALL MDxInit( MDxSum * );
  40712. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  40713. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  40714. const char * STDCALL MDxGetVersion();
  40715. void STDCALL MDxFinalize( MDxSum * );
  40716.  
  40717.  
  40718.  
  40719. #include "mdx.h"
  40720. #include <stdlib.h>
  40721. #include <stdio.h>
  40722. #include <string.h>
  40723.  
  40724. // READLEN % 64 must = 0
  40725. #define READLEN    1048576L // 2^20, 1MB
  40726.  
  40727. void DigestFile( char * );
  40728. void DigestString();
  40729.  
  40730. void main(int argc, char *argv[])
  40731. {
  40732.     printf("%s\n\n", MDxGetVersion());
  40733.  
  40734.     if( argc > 1 )
  40735.         DigestFile( argv[1] );
  40736.     else    
  40737.         DigestString();
  40738.  
  40739. }
  40740.  
  40741. /*
  40742.     I use the 'chunk' method for processing files not because of
  40743.     limitations of my dll, but think what would happen if you
  40744.     tried to load an entire cd image into memory.
  40745. */
  40746. void DigestFile( char *szFName )
  40747. {
  40748.     FILE *file;
  40749.     void *lpData;
  40750.     long flen, mlen;
  40751.     MDxSum mdDataSum;
  40752.     MDxSum md4DataSum;
  40753.  
  40754.     // the 64 is for padding purposes
  40755.     lpData = malloc( READLEN + 64 );
  40756.     
  40757.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40758.  
  40759.     file = fopen( szFName, "rb" );
  40760.     if( file == NULL )
  40761.     {
  40762.         printf("ERROR: File not found.\n");
  40763.         return;
  40764.     }
  40765.     
  40766.     MDxInit( &mdDataSum );
  40767.     MDxInit( &md4DataSum );
  40768.     
  40769.     fseek( file, 0, SEEK_END );
  40770.     //Get the file length
  40771.     flen = mlen = ftell( file );
  40772.     fseek( file, 0, SEEK_SET );
  40773.     
  40774.     // When it takes a while to process a large file,
  40775.     // remember that for each chunk it has to run 
  40776.     // through the main translation loop 16384 times!
  40777.         
  40778.     printf("Processing %ld byte file: .", flen );
  40779.     
  40780.     while( flen > READLEN )
  40781.     {
  40782.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40783.         {
  40784.             printf("READ ERROR!\n");
  40785.             return;
  40786.         }
  40787.         MD5Translate( lpData, READLEN, &mdDataSum );
  40788.         MD4Translate( lpData, READLEN, &md4DataSum );
  40789.         flen -= READLEN;
  40790.         printf(".");
  40791.     }
  40792.  
  40793.     if (fread( lpData, 1, flen, file ) != flen)
  40794.     {
  40795.         printf("READ ERROR!\n");
  40796.         return;
  40797.     }
  40798.     // This is why I added the new argument to MDxPad
  40799.     // So we can pass the length of the data AND the
  40800.     // Total length of the message
  40801.     // Also it now returns the # of padding bytes added,
  40802.     // this is for files that are an exact multiple of the chunk
  40803.     // length. (Otherwise the padding isn't Translated)
  40804.     flen += MDxPad( lpData, flen, mlen );
  40805.     MD5Translate( lpData, flen, &mdDataSum );    
  40806.     MD4Translate( lpData, flen, &md4DataSum );
  40807.  
  40808.     // New step necessary because of the 'chunking' method
  40809.     MDxFinalize( &mdDataSum );
  40810.     MDxFinalize( &md4DataSum );
  40811.     
  40812.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40813.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40814.     fclose(file);
  40815.         
  40816. }
  40817.  
  40818. void DigestString()
  40819. {
  40820.     
  40821.     //For our demo purposes, no strings bigger than 1024 :)
  40822.     unsigned char lpData[1024] = "";
  40823.     long len = 0;
  40824.     MDxSum mdDataSum;
  40825.  
  40826.     printf("Enter the string to digest: ");
  40827.     scanf("%s", &lpData );
  40828.     len = strlen(lpData);
  40829.     
  40830.     // Have to do this before the Padding...well...it's best anyway;)
  40831.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40832.     
  40833.     // For the strings, we're gonna pad and digest the string
  40834.     // in one pass.
  40835.     MDxInit( &mdDataSum );
  40836.     MDxPad( lpData, len, len );
  40837.     
  40838.     MD5Translate( lpData, len, &mdDataSum );
  40839.         // New step necessary because of the 'chunking' method
  40840.         MDxFinalize( &mdDataSum );
  40841.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40842.     
  40843.     MDxInit( &mdDataSum );
  40844.     MD4Translate( lpData, len, &mdDataSum );    
  40845.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40846.  
  40847.     return;
  40848. }
  40849.  
  40850.  
  40851. -------------- Include
  40852.  
  40853. #ifndef __windows_h__
  40854.         typedef unsigned long DWORD;
  40855.         #define STDCALL _stdcall
  40856. #endif
  40857.  
  40858. typedef struct 
  40859. {
  40860.     DWORD dwSum[4];
  40861. }MDxSum;
  40862.  
  40863. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  40864. void STDCALL MDxInit( MDxSum * );
  40865. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  40866. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  40867. const char * STDCALL MDxGetVersion();
  40868. void STDCALL MDxFinalize( MDxSum * );
  40869.  
  40870.  
  40871.  
  40872. #include "mdx.h"
  40873. #include <stdlib.h>
  40874. #include <stdio.h>
  40875. #include <string.h>
  40876.  
  40877. // READLEN % 64 must = 0
  40878. #define READLEN    1048576L // 2^20, 1MB
  40879.  
  40880. void DigestFile( char * );
  40881. void DigestString();
  40882.  
  40883. void main(int argc, char *argv[])
  40884. {
  40885.     printf("%s\n\n", MDxGetVersion());
  40886.  
  40887.     if( argc > 1 )
  40888.         DigestFile( argv[1] );
  40889.     else    
  40890.         DigestString();
  40891.  
  40892. }
  40893.  
  40894. /*
  40895.     I use the 'chunk' method for processing files not because of
  40896.     limitations of my dll, but think what would happen if you
  40897.     tried to load an entire cd image into memory.
  40898. */
  40899. void DigestFile( char *szFName )
  40900. {
  40901.     FILE *file;
  40902.     void *lpData;
  40903.     long flen, mlen;
  40904.     MDxSum mdDataSum;
  40905.     MDxSum md4DataSum;
  40906.  
  40907.     // the 64 is for padding purposes
  40908.     lpData = malloc( READLEN + 64 );
  40909.     
  40910.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  40911.  
  40912.     file = fopen( szFName, "rb" );
  40913.     if( file == NULL )
  40914.     {
  40915.         printf("ERROR: File not found.\n");
  40916.         return;
  40917.     }
  40918.     
  40919.     MDxInit( &mdDataSum );
  40920.     MDxInit( &md4DataSum );
  40921.     
  40922.     fseek( file, 0, SEEK_END );
  40923.     //Get the file length
  40924.     flen = mlen = ftell( file );
  40925.     fseek( file, 0, SEEK_SET );
  40926.     
  40927.     // When it takes a while to process a large file,
  40928.     // remember that for each chunk it has to run 
  40929.     // through the main translation loop 16384 times!
  40930.         
  40931.     printf("Processing %ld byte file: .", flen );
  40932.     
  40933.     while( flen > READLEN )
  40934.     {
  40935.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  40936.         {
  40937.             printf("READ ERROR!\n");
  40938.             return;
  40939.         }
  40940.         MD5Translate( lpData, READLEN, &mdDataSum );
  40941.         MD4Translate( lpData, READLEN, &md4DataSum );
  40942.         flen -= READLEN;
  40943.         printf(".");
  40944.     }
  40945.  
  40946.     if (fread( lpData, 1, flen, file ) != flen)
  40947.     {
  40948.         printf("READ ERROR!\n");
  40949.         return;
  40950.     }
  40951.     // This is why I added the new argument to MDxPad
  40952.     // So we can pass the length of the data AND the
  40953.     // Total length of the message
  40954.     // Also it now returns the # of padding bytes added,
  40955.     // this is for files that are an exact multiple of the chunk
  40956.     // length. (Otherwise the padding isn't Translated)
  40957.     flen += MDxPad( lpData, flen, mlen );
  40958.     MD5Translate( lpData, flen, &mdDataSum );    
  40959.     MD4Translate( lpData, flen, &md4DataSum );
  40960.  
  40961.     // New step necessary because of the 'chunking' method
  40962.     MDxFinalize( &mdDataSum );
  40963.     MDxFinalize( &md4DataSum );
  40964.     
  40965.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  40966.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40967.     fclose(file);
  40968.         
  40969. }
  40970.  
  40971. void DigestString()
  40972. {
  40973.     
  40974.     //For our demo purposes, no strings bigger than 1024 :)
  40975.     unsigned char lpData[1024] = "";
  40976.     long len = 0;
  40977.     MDxSum mdDataSum;
  40978.  
  40979.     printf("Enter the string to digest: ");
  40980.     scanf("%s", &lpData );
  40981.     len = strlen(lpData);
  40982.     
  40983.     // Have to do this before the Padding...well...it's best anyway;)
  40984.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  40985.     
  40986.     // For the strings, we're gonna pad and digest the string
  40987.     // in one pass.
  40988.     MDxInit( &mdDataSum );
  40989.     MDxPad( lpData, len, len );
  40990.     
  40991.     MD5Translate( lpData, len, &mdDataSum );
  40992.         // New step necessary because of the 'chunking' method
  40993.         MDxFinalize( &mdDataSum );
  40994.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40995.     
  40996.     MDxInit( &mdDataSum );
  40997.     MD4Translate( lpData, len, &mdDataSum );    
  40998.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  40999.  
  41000.     return;
  41001. }
  41002.  
  41003.  
  41004. -------------- Include
  41005.  
  41006. #ifndef __windows_h__
  41007.         typedef unsigned long DWORD;
  41008.         #define STDCALL _stdcall
  41009. #endif
  41010.  
  41011. typedef struct 
  41012. {
  41013.     DWORD dwSum[4];
  41014. }MDxSum;
  41015.  
  41016. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41017. void STDCALL MDxInit( MDxSum * );
  41018. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41019. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41020. const char * STDCALL MDxGetVersion();
  41021. void STDCALL MDxFinalize( MDxSum * );
  41022.  
  41023.  
  41024.  
  41025. #include "mdx.h"
  41026. #include <stdlib.h>
  41027. #include <stdio.h>
  41028. #include <string.h>
  41029.  
  41030. // READLEN % 64 must = 0
  41031. #define READLEN    1048576L // 2^20, 1MB
  41032.  
  41033. void DigestFile( char * );
  41034. void DigestString();
  41035.  
  41036. void main(int argc, char *argv[])
  41037. {
  41038.     printf("%s\n\n", MDxGetVersion());
  41039.  
  41040.     if( argc > 1 )
  41041.         DigestFile( argv[1] );
  41042.     else    
  41043.         DigestString();
  41044.  
  41045. }
  41046.  
  41047. /*
  41048.     I use the 'chunk' method for processing files not because of
  41049.     limitations of my dll, but think what would happen if you
  41050.     tried to load an entire cd image into memory.
  41051. */
  41052. void DigestFile( char *szFName )
  41053. {
  41054.     FILE *file;
  41055.     void *lpData;
  41056.     long flen, mlen;
  41057.     MDxSum mdDataSum;
  41058.     MDxSum md4DataSum;
  41059.  
  41060.     // the 64 is for padding purposes
  41061.     lpData = malloc( READLEN + 64 );
  41062.     
  41063.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41064.  
  41065.     file = fopen( szFName, "rb" );
  41066.     if( file == NULL )
  41067.     {
  41068.         printf("ERROR: File not found.\n");
  41069.         return;
  41070.     }
  41071.     
  41072.     MDxInit( &mdDataSum );
  41073.     MDxInit( &md4DataSum );
  41074.     
  41075.     fseek( file, 0, SEEK_END );
  41076.     //Get the file length
  41077.     flen = mlen = ftell( file );
  41078.     fseek( file, 0, SEEK_SET );
  41079.     
  41080.     // When it takes a while to process a large file,
  41081.     // remember that for each chunk it has to run 
  41082.     // through the main translation loop 16384 times!
  41083.         
  41084.     printf("Processing %ld byte file: .", flen );
  41085.     
  41086.     while( flen > READLEN )
  41087.     {
  41088.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  41089.         {
  41090.             printf("READ ERROR!\n");
  41091.             return;
  41092.         }
  41093.         MD5Translate( lpData, READLEN, &mdDataSum );
  41094.         MD4Translate( lpData, READLEN, &md4DataSum );
  41095.         flen -= READLEN;
  41096.         printf(".");
  41097.     }
  41098.  
  41099.     if (fread( lpData, 1, flen, file ) != flen)
  41100.     {
  41101.         printf("READ ERROR!\n");
  41102.         return;
  41103.     }
  41104.     // This is why I added the new argument to MDxPad
  41105.     // So we can pass the length of the data AND the
  41106.     // Total length of the message
  41107.     // Also it now returns the # of padding bytes added,
  41108.     // this is for files that are an exact multiple of the chunk
  41109.     // length. (Otherwise the padding isn't Translated)
  41110.     flen += MDxPad( lpData, flen, mlen );
  41111.     MD5Translate( lpData, flen, &mdDataSum );    
  41112.     MD4Translate( lpData, flen, &md4DataSum );
  41113.  
  41114.     // New step necessary because of the 'chunking' method
  41115.     MDxFinalize( &mdDataSum );
  41116.     MDxFinalize( &md4DataSum );
  41117.     
  41118.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  41119.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41120.     fclose(file);
  41121.         
  41122. }
  41123.  
  41124. void DigestString()
  41125. {
  41126.     
  41127.     //For our demo purposes, no strings bigger than 1024 :)
  41128.     unsigned char lpData[1024] = "";
  41129.     long len = 0;
  41130.     MDxSum mdDataSum;
  41131.  
  41132.     printf("Enter the string to digest: ");
  41133.     scanf("%s", &lpData );
  41134.     len = strlen(lpData);
  41135.     
  41136.     // Have to do this before the Padding...well...it's best anyway;)
  41137.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  41138.     
  41139.     // For the strings, we're gonna pad and digest the string
  41140.     // in one pass.
  41141.     MDxInit( &mdDataSum );
  41142.     MDxPad( lpData, len, len );
  41143.     
  41144.     MD5Translate( lpData, len, &mdDataSum );
  41145.         // New step necessary because of the 'chunking' method
  41146.         MDxFinalize( &mdDataSum );
  41147.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41148.     
  41149.     MDxInit( &mdDataSum );
  41150.     MD4Translate( lpData, len, &mdDataSum );    
  41151.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41152.  
  41153.     return;
  41154. }
  41155.  
  41156.  
  41157. -------------- Include
  41158.  
  41159. #ifndef __windows_h__
  41160.         typedef unsigned long DWORD;
  41161.         #define STDCALL _stdcall
  41162. #endif
  41163.  
  41164. typedef struct 
  41165. {
  41166.     DWORD dwSum[4];
  41167. }MDxSum;
  41168.  
  41169. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41170. void STDCALL MDxInit( MDxSum * );
  41171. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41172. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41173. const char * STDCALL MDxGetVersion();
  41174. void STDCALL MDxFinalize( MDxSum * );
  41175.  
  41176.  
  41177.  
  41178. #include "mdx.h"
  41179. #include <stdlib.h>
  41180. #include <stdio.h>
  41181. #include <string.h>
  41182.  
  41183. // READLEN % 64 must = 0
  41184. #define READLEN    1048576L // 2^20, 1MB
  41185.  
  41186. void DigestFile( char * );
  41187. void DigestString();
  41188.  
  41189. void main(int argc, char *argv[])
  41190. {
  41191.     printf("%s\n\n", MDxGetVersion());
  41192.  
  41193.     if( argc > 1 )
  41194.         DigestFile( argv[1] );
  41195.     else    
  41196.         DigestString();
  41197.  
  41198. }
  41199.  
  41200. /*
  41201.     I use the 'chunk' method for processing files not because of
  41202.     limitations of my dll, but think what would happen if you
  41203.     tried to load an entire cd image into memory.
  41204. */
  41205. void DigestFile( char *szFName )
  41206. {
  41207.     FILE *file;
  41208.     void *lpData;
  41209.     long flen, mlen;
  41210.     MDxSum mdDataSum;
  41211.     MDxSum md4DataSum;
  41212.  
  41213.     // the 64 is for padding purposes
  41214.     lpData = malloc( READLEN + 64 );
  41215.     
  41216.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41217.  
  41218.     file = fopen( szFName, "rb" );
  41219.     if( file == NULL )
  41220.     {
  41221.         printf("ERROR: File not found.\n");
  41222.         return;
  41223.     }
  41224.     
  41225.     MDxInit( &mdDataSum );
  41226.     MDxInit( &md4DataSum );
  41227.     
  41228.     fseek( file, 0, SEEK_END );
  41229.     //Get the file length
  41230.     flen = mlen = ftell( file );
  41231.     fseek( file, 0, SEEK_SET );
  41232.     
  41233.     // When it takes a while to process a large file,
  41234.     // remember that for each chunk it has to run 
  41235.     // through the main translation loop 16384 times!
  41236.         
  41237.     printf("Processing %ld byte file: .", flen );
  41238.     
  41239.     while( flen > READLEN )
  41240.     {
  41241.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  41242.         {
  41243.             printf("READ ERROR!\n");
  41244.             return;
  41245.         }
  41246.         MD5Translate( lpData, READLEN, &mdDataSum );
  41247.         MD4Translate( lpData, READLEN, &md4DataSum );
  41248.         flen -= READLEN;
  41249.         printf(".");
  41250.     }
  41251.  
  41252.     if (fread( lpData, 1, flen, file ) != flen)
  41253.     {
  41254.         printf("READ ERROR!\n");
  41255.         return;
  41256.     }
  41257.     // This is why I added the new argument to MDxPad
  41258.     // So we can pass the length of the data AND the
  41259.     // Total length of the message
  41260.     // Also it now returns the # of padding bytes added,
  41261.     // this is for files that are an exact multiple of the chunk
  41262.     // length. (Otherwise the padding isn't Translated)
  41263.     flen += MDxPad( lpData, flen, mlen );
  41264.     MD5Translate( lpData, flen, &mdDataSum );    
  41265.     MD4Translate( lpData, flen, &md4DataSum );
  41266.  
  41267.     // New step necessary because of the 'chunking' method
  41268.     MDxFinalize( &mdDataSum );
  41269.     MDxFinalize( &md4DataSum );
  41270.     
  41271.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  41272.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41273.     fclose(file);
  41274.         
  41275. }
  41276.  
  41277. void DigestString()
  41278. {
  41279.     
  41280.     //For our demo purposes, no strings bigger than 1024 :)
  41281.     unsigned char lpData[1024] = "";
  41282.     long len = 0;
  41283.     MDxSum mdDataSum;
  41284.  
  41285.     printf("Enter the string to digest: ");
  41286.     scanf("%s", &lpData );
  41287.     len = strlen(lpData);
  41288.     
  41289.     // Have to do this before the Padding...well...it's best anyway;)
  41290.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  41291.     
  41292.     // For the strings, we're gonna pad and digest the string
  41293.     // in one pass.
  41294.     MDxInit( &mdDataSum );
  41295.     MDxPad( lpData, len, len );
  41296.     
  41297.     MD5Translate( lpData, len, &mdDataSum );
  41298.         // New step necessary because of the 'chunking' method
  41299.         MDxFinalize( &mdDataSum );
  41300.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41301.     
  41302.     MDxInit( &mdDataSum );
  41303.     MD4Translate( lpData, len, &mdDataSum );    
  41304.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41305.  
  41306.     return;
  41307. }
  41308.  
  41309.  
  41310. -------------- Include
  41311.  
  41312. #ifndef __windows_h__
  41313.         typedef unsigned long DWORD;
  41314.         #define STDCALL _stdcall
  41315. #endif
  41316.  
  41317. typedef struct 
  41318. {
  41319.     DWORD dwSum[4];
  41320. }MDxSum;
  41321.  
  41322. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41323. void STDCALL MDxInit( MDxSum * );
  41324. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41325. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41326. const char * STDCALL MDxGetVersion();
  41327. void STDCALL MDxFinalize( MDxSum * );
  41328.  
  41329.  
  41330. #include "mdx.h"
  41331. #include <stdlib.h>
  41332. #include <stdio.h>
  41333. #include <string.h>
  41334.  
  41335. // READLEN % 64 must = 0
  41336. #define READLEN    1048576L // 2^20, 1MB
  41337.  
  41338. void DigestFile( char * );
  41339. void DigestString();
  41340.  
  41341. void main(int argc, char *argv[])
  41342. {
  41343.     printf("%s\n\n", MDxGetVersion());
  41344.  
  41345.     if( argc > 1 )
  41346.         DigestFile( argv[1] );
  41347.     else    
  41348.         DigestString();
  41349.  
  41350. }
  41351.  
  41352. /*
  41353.     I use the 'chunk' method for processing files not because of
  41354.     limitations of my dll, but think what would happen if you
  41355.     tried to load an entire cd image into memory.
  41356. */
  41357. void DigestFile( char *szFName )
  41358. {
  41359.     FILE *file;
  41360.     void *lpData;
  41361.     long flen, mlen;
  41362.     MDxSum mdDataSum;
  41363.     MDxSum md4DataSum;
  41364.  
  41365.     // the 64 is for padding purposes
  41366.     lpData = malloc( READLEN + 64 );
  41367.     
  41368.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41369.  
  41370.     file = fopen( szFName, "rb" );
  41371.     if( file == NULL )
  41372.     {
  41373.         printf("ERROR: File not found.\n");
  41374.         return;
  41375.     }
  41376.     
  41377.     MDxInit( &mdDataSum );
  41378.     MDxInit( &md4DataSum );
  41379.     
  41380.     fseek( file, 0, SEEK_END );
  41381.     //Get the file length
  41382.     flen = mlen = ftell( file );
  41383.     fseek( file, 0, SEEK_SET );
  41384.     
  41385.     // When it takes a while to process a large file,
  41386.     // remember that for each chunk it has to run 
  41387.     // through the main translation loop 16384 times!
  41388.         
  41389.     printf("Processing %ld byte file: .", flen );
  41390.     
  41391.     while( flen > READLEN )
  41392.     {
  41393.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  41394.         {
  41395.             printf("READ ERROR!\n");
  41396.             return;
  41397.         }
  41398.         MD5Translate( lpData, READLEN, &mdDataSum );
  41399.         MD4Translate( lpData, READLEN, &md4DataSum );
  41400.         flen -= READLEN;
  41401.         printf(".");
  41402.     }
  41403.  
  41404.     if (fread( lpData, 1, flen, file ) != flen)
  41405.     {
  41406.         printf("READ ERROR!\n");
  41407.         return;
  41408.     }
  41409.     // This is why I added the new argument to MDxPad
  41410.     // So we can pass the length of the data AND the
  41411.     // Total length of the message
  41412.     // Also it now returns the # of padding bytes added,
  41413.     // this is for files that are an exact multiple of the chunk
  41414.     // length. (Otherwise the padding isn't Translated)
  41415.     flen += MDxPad( lpData, flen, mlen );
  41416.     MD5Translate( lpData, flen, &mdDataSum );    
  41417.     MD4Translate( lpData, flen, &md4DataSum );
  41418.  
  41419.     // New step necessary because of the 'chunking' method
  41420.     MDxFinalize( &mdDataSum );
  41421.     MDxFinalize( &md4DataSum );
  41422.     
  41423.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  41424.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41425.     fclose(file);
  41426.         
  41427. }
  41428.  
  41429. void DigestString()
  41430. {
  41431.     
  41432.     //For our demo purposes, no strings bigger than 1024 :)
  41433.     unsigned char lpData[1024] = "";
  41434.     long len = 0;
  41435.     MDxSum mdDataSum;
  41436.  
  41437.     printf("Enter the string to digest: ");
  41438.     scanf("%s", &lpData );
  41439.     len = strlen(lpData);
  41440.     
  41441.     // Have to do this before the Padding...well...it's best anyway;)
  41442.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  41443.     
  41444.     // For the strings, we're gonna pad and digest the string
  41445.     // in one pass.
  41446.     MDxInit( &mdDataSum );
  41447.     MDxPad( lpData, len, len );
  41448.     
  41449.     MD5Translate( lpData, len, &mdDataSum );
  41450.         // New step necessary because of the 'chunking' method
  41451.         MDxFinalize( &mdDataSum );
  41452.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41453.     
  41454.     MDxInit( &mdDataSum );
  41455.     MD4Translate( lpData, len, &mdDataSum );    
  41456.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41457.  
  41458.     return;
  41459. }
  41460.  
  41461.  
  41462. -------------- Include
  41463.  
  41464. #ifndef __windows_h__
  41465.         typedef unsigned long DWORD;
  41466.         #define STDCALL _stdcall
  41467. #endif
  41468.  
  41469. typedef struct 
  41470. {
  41471.     DWORD dwSum[4];
  41472. }MDxSum;
  41473.  
  41474. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41475. void STDCALL MDxInit( MDxSum * );
  41476. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41477. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41478. const char * STDCALL MDxGetVersion();
  41479. void STDCALL MDxFinalize( MDxSum * );
  41480.  
  41481.  
  41482. #include "mdx.h"
  41483. #include <stdlib.h>
  41484. #include <stdio.h>
  41485. #include <string.h>
  41486.  
  41487. // READLEN % 64 must = 0
  41488. #define READLEN    1048576L // 2^20, 1MB
  41489.  
  41490. void DigestFile( char * );
  41491. void DigestString();
  41492.  
  41493. void main(int argc, char *argv[])
  41494. {
  41495.     printf("%s\n\n", MDxGetVersion());
  41496.  
  41497.     if( argc > 1 )
  41498.         DigestFile( argv[1] );
  41499.     else    
  41500.         DigestString();
  41501.  
  41502. }
  41503.  
  41504. /*
  41505.     I use the 'chunk' method for processing files not because of
  41506.     limitations of my dll, but think what would happen if you
  41507.     tried to load an entire cd image into memory.
  41508. */
  41509. void DigestFile( char *szFName )
  41510. {
  41511.     FILE *file;
  41512.     void *lpData;
  41513.     long flen, mlen;
  41514.     MDxSum mdDataSum;
  41515.     MDxSum md4DataSum;
  41516.  
  41517.     // the 64 is for padding purposes
  41518.     lpData = malloc( READLEN + 64 );
  41519.     
  41520.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41521.  
  41522.     file = fopen( szFName, "rb" );
  41523.     if( file == NULL )
  41524.     {
  41525.         printf("ERROR: File not found.\n");
  41526.         return;
  41527.     }
  41528.     
  41529.     MDxInit( &mdDataSum );
  41530.     MDxInit( &md4DataSum );
  41531.     
  41532.     fseek( file, 0, SEEK_END );
  41533.     //Get the file length
  41534.     flen = mlen = ftell( file );
  41535.     fseek( file, 0, SEEK_SET );
  41536.     
  41537.     // When it takes a while to process a large file,
  41538.     // remember that for each chunk it has to run 
  41539.     // through the main translation loop 16384 times!
  41540.         
  41541.     printf("Processing %ld byte file: .", flen );
  41542.     
  41543.     while( flen > READLEN )
  41544.     {
  41545.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  41546.         {
  41547.             printf("READ ERROR!\n");
  41548.             return;
  41549.         }
  41550.         MD5Translate( lpData, READLEN, &mdDataSum );
  41551.         MD4Translate( lpData, READLEN, &md4DataSum );
  41552.         flen -= READLEN;
  41553.         printf(".");
  41554.     }
  41555.  
  41556.     if (fread( lpData, 1, flen, file ) != flen)
  41557.     {
  41558.         printf("READ ERROR!\n");
  41559.         return;
  41560.     }
  41561.     // This is why I added the new argument to MDxPad
  41562.     // So we can pass the length of the data AND the
  41563.     // Total length of the message
  41564.     // Also it now returns the # of padding bytes added,
  41565.     // this is for files that are an exact multiple of the chunk
  41566.     // length. (Otherwise the padding isn't Translated)
  41567.     flen += MDxPad( lpData, flen, mlen );
  41568.     MD5Translate( lpData, flen, &mdDataSum );    
  41569.     MD4Translate( lpData, flen, &md4DataSum );
  41570.  
  41571.     // New step necessary because of the 'chunking' method
  41572.     MDxFinalize( &mdDataSum );
  41573.     MDxFinalize( &md4DataSum );
  41574.     
  41575.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  41576.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41577.     fclose(file);
  41578.         
  41579. }
  41580.  
  41581. void DigestString()
  41582. {
  41583.     
  41584.     //For our demo purposes, no strings bigger than 1024 :)
  41585.     unsigned char lpData[1024] = "";
  41586.     long len = 0;
  41587.     MDxSum mdDataSum;
  41588.  
  41589.     printf("Enter the string to digest: ");
  41590.     scanf("%s", &lpData );
  41591.     len = strlen(lpData);
  41592.     
  41593.     // Have to do this before the Padding...well...it's best anyway;)
  41594.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  41595.     
  41596.     // For the strings, we're gonna pad and digest the string
  41597.     // in one pass.
  41598.     MDxInit( &mdDataSum );
  41599.     MDxPad( lpData, len, len );
  41600.     
  41601.     MD5Translate( lpData, len, &mdDataSum );
  41602.         // New step necessary because of the 'chunking' method
  41603.         MDxFinalize( &mdDataSum );
  41604.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41605.     
  41606.     MDxInit( &mdDataSum );
  41607.     MD4Translate( lpData, len, &mdDataSum );    
  41608.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41609.  
  41610.     return;
  41611. }
  41612.  
  41613.  
  41614. -------------- Include
  41615.  
  41616. #ifndef __windows_h__
  41617.         typedef unsigned long DWORD;
  41618.         #define STDCALL _stdcall
  41619. #endif
  41620.  
  41621. typedef struct 
  41622. {
  41623.     DWORD dwSum[4];
  41624. }MDxSum;
  41625.  
  41626. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41627. void STDCALL MDxInit( MDxSum * );
  41628. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41629. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41630. const char * STDCALL MDxGetVersion();
  41631. void STDCALL MDxFinalize( MDxSum * );
  41632.  
  41633. #include "mdx.h"
  41634. #include <stdlib.h>
  41635. #include <stdio.h>
  41636. #include <string.h>
  41637.  
  41638. // READLEN % 64 must = 0
  41639. #define READLEN    1048576L // 2^20, 1MB
  41640.  
  41641. void DigestFile( char * );
  41642. void DigestString();
  41643.  
  41644. void main(int argc, char *argv[])
  41645. {
  41646.     printf("%s\n\n", MDxGetVersion());
  41647.  
  41648.     if( argc > 1 )
  41649.         DigestFile( argv[1] );
  41650.     else    
  41651.         DigestString();
  41652.  
  41653. }
  41654.  
  41655. /*
  41656.     I use the 'chunk' method for processing files not because of
  41657.     limitations of my dll, but think what would happen if you
  41658.     tried to load an entire cd image into memory.
  41659. */
  41660. void DigestFile( char *szFName )
  41661. {
  41662.     FILE *file;
  41663.     void *lpData;
  41664.     long flen, mlen;
  41665.     MDxSum mdDataSum;
  41666.     MDxSum md4DataSum;
  41667.  
  41668.     // the 64 is for padding purposes
  41669.     lpData = malloc( READLEN + 64 );
  41670.     
  41671.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41672.  
  41673.     file = fopen( szFName, "rb" );
  41674.     if( file == NULL )
  41675.     {
  41676.         printf("ERROR: File not found.\n");
  41677.         return;
  41678.     }
  41679.     
  41680.     MDxInit( &mdDataSum );
  41681.     MDxInit( &md4DataSum );
  41682.     
  41683.     fseek( file, 0, SEEK_END );
  41684.     //Get the file length
  41685.     flen = mlen = ftell( file );
  41686.     fseek( file, 0, SEEK_SET );
  41687.     
  41688.     // When it takes a while to process a large file,
  41689.     // remember that for each chunk it has to run 
  41690.     // through the main translation loop 16384 times!
  41691.         
  41692.     printf("Processing %ld byte file: .", flen );
  41693.     
  41694.     while( flen > READLEN )
  41695.     {
  41696.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  41697.         {
  41698.             printf("READ ERROR!\n");
  41699.             return;
  41700.         }
  41701.         MD5Translate( lpData, READLEN, &mdDataSum );
  41702.         MD4Translate( lpData, READLEN, &md4DataSum );
  41703.         flen -= READLEN;
  41704.         printf(".");
  41705.     }
  41706.  
  41707.     if (fread( lpData, 1, flen, file ) != flen)
  41708.     {
  41709.         printf("READ ERROR!\n");
  41710.         return;
  41711.     }
  41712.     // This is why I added the new argument to MDxPad
  41713.     // So we can pass the length of the data AND the
  41714.     // Total length of the message
  41715.     // Also it now returns the # of padding bytes added,
  41716.     // this is for files that are an exact multiple of the chunk
  41717.     // length. (Otherwise the padding isn't Translated)
  41718.     flen += MDxPad( lpData, flen, mlen );
  41719.     MD5Translate( lpData, flen, &mdDataSum );    
  41720.     MD4Translate( lpData, flen, &md4DataSum );
  41721.  
  41722.     // New step necessary because of the 'chunking' method
  41723.     MDxFinalize( &mdDataSum );
  41724.     MDxFinalize( &md4DataSum );
  41725.     
  41726.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  41727.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41728.     fclose(file);
  41729.         
  41730. }
  41731.  
  41732. void DigestString()
  41733. {
  41734.     
  41735.     //For our demo purposes, no strings bigger than 1024 :)
  41736.     unsigned char lpData[1024] = "";
  41737.     long len = 0;
  41738.     MDxSum mdDataSum;
  41739.  
  41740.     printf("Enter the string to digest: ");
  41741.     scanf("%s", &lpData );
  41742.     len = strlen(lpData);
  41743.     
  41744.     // Have to do this before the Padding...well...it's best anyway;)
  41745.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  41746.     
  41747.     // For the strings, we're gonna pad and digest the string
  41748.     // in one pass.
  41749.     MDxInit( &mdDataSum );
  41750.     MDxPad( lpData, len, len );
  41751.     
  41752.     MD5Translate( lpData, len, &mdDataSum );
  41753.         // New step necessary because of the 'chunking' method
  41754.         MDxFinalize( &mdDataSum );
  41755.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41756.     
  41757.     MDxInit( &mdDataSum );
  41758.     MD4Translate( lpData, len, &mdDataSum );    
  41759.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41760.  
  41761.     return;
  41762. }
  41763.  
  41764.  
  41765. -------------- Include
  41766.  
  41767. #ifndef __windows_h__
  41768.         typedef unsigned long DWORD;
  41769.         #define STDCALL _stdcall
  41770. #endif
  41771.  
  41772. typedef struct 
  41773. {
  41774.     DWORD dwSum[4];
  41775. }MDxSum;
  41776.  
  41777. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41778. void STDCALL MDxInit( MDxSum * );
  41779. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41780. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41781. const char * STDCALL MDxGetVersion();
  41782. void STDCALL MDxFinalize( MDxSum * );
  41783.  
  41784.  
  41785.  
  41786. #include "mdx.h"
  41787. #include <stdlib.h>
  41788. #include <stdio.h>
  41789. #include <string.h>
  41790.  
  41791. // READLEN % 64 must = 0
  41792. #define READLEN    1048576L // 2^20, 1MB
  41793.  
  41794. void DigestFile( char * );
  41795. void DigestString();
  41796.  
  41797. void main(int argc, char *argv[])
  41798. {
  41799.     printf("%s\n\n", MDxGetVersion());
  41800.  
  41801.     if( argc > 1 )
  41802.         DigestFile( argv[1] );
  41803.     else    
  41804.         DigestString();
  41805.  
  41806. }
  41807.  
  41808. /*
  41809.     I use the 'chunk' method for processing files not because of
  41810.     limitations of my dll, but think what would happen if you
  41811.     tried to load an entire cd image into memory.
  41812. */
  41813. void DigestFile( char *szFName )
  41814. {
  41815.     FILE *file;
  41816.     void *lpData;
  41817.     long flen, mlen;
  41818.     MDxSum mdDataSum;
  41819.     MDxSum md4DataSum;
  41820.  
  41821.     // the 64 is for padding purposes
  41822.     lpData = malloc( READLEN + 64 );
  41823.     
  41824.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41825.  
  41826.     file = fopen( szFName, "rb" );
  41827.     if( file == NULL )
  41828.     {
  41829.         printf("ERROR: File not found.\n");
  41830.         return;
  41831.     }
  41832.     
  41833.     MDxInit( &mdDataSum );
  41834.     MDxInit( &md4DataSum );
  41835.     
  41836.     fseek( file, 0, SEEK_END );
  41837.     //Get the file length
  41838.     flen = mlen = ftell( file );
  41839.     fseek( file, 0, SEEK_SET );
  41840.     
  41841.     // When it takes a while to process a large file,
  41842.     // remember that for each chunk it has to run 
  41843.     // through the main translation loop 16384 times!
  41844.         
  41845.     printf("Processing %ld byte file: .", flen );
  41846.     
  41847.     while( flen > READLEN )
  41848.     {
  41849.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  41850.         {
  41851.             printf("READ ERROR!\n");
  41852.             return;
  41853.         }
  41854.         MD5Translate( lpData, READLEN, &mdDataSum );
  41855.         MD4Translate( lpData, READLEN, &md4DataSum );
  41856.         flen -= READLEN;
  41857.         printf(".");
  41858.     }
  41859.  
  41860.     if (fread( lpData, 1, flen, file ) != flen)
  41861.     {
  41862.         printf("READ ERROR!\n");
  41863.         return;
  41864.     }
  41865.     // This is why I added the new argument to MDxPad
  41866.     // So we can pass the length of the data AND the
  41867.     // Total length of the message
  41868.     // Also it now returns the # of padding bytes added,
  41869.     // this is for files that are an exact multiple of the chunk
  41870.     // length. (Otherwise the padding isn't Translated)
  41871.     flen += MDxPad( lpData, flen, mlen );
  41872.     MD5Translate( lpData, flen, &mdDataSum );    
  41873.     MD4Translate( lpData, flen, &md4DataSum );
  41874.  
  41875.     // New step necessary because of the 'chunking' method
  41876.     MDxFinalize( &mdDataSum );
  41877.     MDxFinalize( &md4DataSum );
  41878.     
  41879.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  41880.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41881.     fclose(file);
  41882.         
  41883. }
  41884.  
  41885. void DigestString()
  41886. {
  41887.     
  41888.     //For our demo purposes, no strings bigger than 1024 :)
  41889.     unsigned char lpData[1024] = "";
  41890.     long len = 0;
  41891.     MDxSum mdDataSum;
  41892.  
  41893.     printf("Enter the string to digest: ");
  41894.     scanf("%s", &lpData );
  41895.     len = strlen(lpData);
  41896.     
  41897.     // Have to do this before the Padding...well...it's best anyway;)
  41898.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  41899.     
  41900.     // For the strings, we're gonna pad and digest the string
  41901.     // in one pass.
  41902.     MDxInit( &mdDataSum );
  41903.     MDxPad( lpData, len, len );
  41904.     
  41905.     MD5Translate( lpData, len, &mdDataSum );
  41906.         // New step necessary because of the 'chunking' method
  41907.         MDxFinalize( &mdDataSum );
  41908.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41909.     
  41910.     MDxInit( &mdDataSum );
  41911.     MD4Translate( lpData, len, &mdDataSum );    
  41912.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  41913.  
  41914.     return;
  41915. }
  41916.  
  41917.  
  41918. -------------- Include
  41919.  
  41920. #ifndef __windows_h__
  41921.         typedef unsigned long DWORD;
  41922.         #define STDCALL _stdcall
  41923. #endif
  41924.  
  41925. typedef struct 
  41926. {
  41927.     DWORD dwSum[4];
  41928. }MDxSum;
  41929.  
  41930. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  41931. void STDCALL MDxInit( MDxSum * );
  41932. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  41933. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  41934. const char * STDCALL MDxGetVersion();
  41935. void STDCALL MDxFinalize( MDxSum * );
  41936.  
  41937.  
  41938.  
  41939. #include "mdx.h"
  41940. #include <stdlib.h>
  41941. #include <stdio.h>
  41942. #include <string.h>
  41943.  
  41944. // READLEN % 64 must = 0
  41945. #define READLEN    1048576L // 2^20, 1MB
  41946.  
  41947. void DigestFile( char * );
  41948. void DigestString();
  41949.  
  41950. void main(int argc, char *argv[])
  41951. {
  41952.     printf("%s\n\n", MDxGetVersion());
  41953.  
  41954.     if( argc > 1 )
  41955.         DigestFile( argv[1] );
  41956.     else    
  41957.         DigestString();
  41958.  
  41959. }
  41960.  
  41961. /*
  41962.     I use the 'chunk' method for processing files not because of
  41963.     limitations of my dll, but think what would happen if you
  41964.     tried to load an entire cd image into memory.
  41965. */
  41966. void DigestFile( char *szFName )
  41967. {
  41968.     FILE *file;
  41969.     void *lpData;
  41970.     long flen, mlen;
  41971.     MDxSum mdDataSum;
  41972.     MDxSum md4DataSum;
  41973.  
  41974.     // the 64 is for padding purposes
  41975.     lpData = malloc( READLEN + 64 );
  41976.     
  41977.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  41978.  
  41979.     file = fopen( szFName, "rb" );
  41980.     if( file == NULL )
  41981.     {
  41982.         printf("ERROR: File not found.\n");
  41983.         return;
  41984.     }
  41985.     
  41986.     MDxInit( &mdDataSum );
  41987.     MDxInit( &md4DataSum );
  41988.     
  41989.     fseek( file, 0, SEEK_END );
  41990.     //Get the file length
  41991.     flen = mlen = ftell( file );
  41992.     fseek( file, 0, SEEK_SET );
  41993.     
  41994.     // When it takes a while to process a large file,
  41995.     // remember that for each chunk it has to run 
  41996.     // through the main translation loop 16384 times!
  41997.         
  41998.     printf("Processing %ld byte file: .", flen );
  41999.     
  42000.     while( flen > READLEN )
  42001.     {
  42002.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42003.         {
  42004.             printf("READ ERROR!\n");
  42005.             return;
  42006.         }
  42007.         MD5Translate( lpData, READLEN, &mdDataSum );
  42008.         MD4Translate( lpData, READLEN, &md4DataSum );
  42009.         flen -= READLEN;
  42010.         printf(".");
  42011.     }
  42012.  
  42013.     if (fread( lpData, 1, flen, file ) != flen)
  42014.     {
  42015.         printf("READ ERROR!\n");
  42016.         return;
  42017.     }
  42018.     // This is why I added the new argument to MDxPad
  42019.     // So we can pass the length of the data AND the
  42020.     // Total length of the message
  42021.     // Also it now returns the # of padding bytes added,
  42022.     // this is for files that are an exact multiple of the chunk
  42023.     // length. (Otherwise the padding isn't Translated)
  42024.     flen += MDxPad( lpData, flen, mlen );
  42025.     MD5Translate( lpData, flen, &mdDataSum );    
  42026.     MD4Translate( lpData, flen, &md4DataSum );
  42027.  
  42028.     // New step necessary because of the 'chunking' method
  42029.     MDxFinalize( &mdDataSum );
  42030.     MDxFinalize( &md4DataSum );
  42031.     
  42032.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42033.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42034.     fclose(file);
  42035.         
  42036. }
  42037.  
  42038. void DigestString()
  42039. {
  42040.     
  42041.     //For our demo purposes, no strings bigger than 1024 :)
  42042.     unsigned char lpData[1024] = "";
  42043.     long len = 0;
  42044.     MDxSum mdDataSum;
  42045.  
  42046.     printf("Enter the string to digest: ");
  42047.     scanf("%s", &lpData );
  42048.     len = strlen(lpData);
  42049.     
  42050.     // Have to do this before the Padding...well...it's best anyway;)
  42051.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42052.     
  42053.     // For the strings, we're gonna pad and digest the string
  42054.     // in one pass.
  42055.     MDxInit( &mdDataSum );
  42056.     MDxPad( lpData, len, len );
  42057.     
  42058.     MD5Translate( lpData, len, &mdDataSum );
  42059.         // New step necessary because of the 'chunking' method
  42060.         MDxFinalize( &mdDataSum );
  42061.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42062.     
  42063.     MDxInit( &mdDataSum );
  42064.     MD4Translate( lpData, len, &mdDataSum );    
  42065.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42066.  
  42067.     return;
  42068. }
  42069.  
  42070.  
  42071. -------------- Include
  42072.  
  42073. #ifndef __windows_h__
  42074.         typedef unsigned long DWORD;
  42075.         #define STDCALL _stdcall
  42076. #endif
  42077.  
  42078. typedef struct 
  42079. {
  42080.     DWORD dwSum[4];
  42081. }MDxSum;
  42082.  
  42083. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  42084. void STDCALL MDxInit( MDxSum * );
  42085. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  42086. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  42087. const char * STDCALL MDxGetVersion();
  42088. void STDCALL MDxFinalize( MDxSum * );
  42089.  
  42090.  
  42091.  
  42092. #include "mdx.h"
  42093. #include <stdlib.h>
  42094. #include <stdio.h>
  42095. #include <string.h>
  42096.  
  42097. // READLEN % 64 must = 0
  42098. #define READLEN    1048576L // 2^20, 1MB
  42099.  
  42100. void DigestFile( char * );
  42101. void DigestString();
  42102.  
  42103. void main(int argc, char *argv[])
  42104. {
  42105.     printf("%s\n\n", MDxGetVersion());
  42106.  
  42107.     if( argc > 1 )
  42108.         DigestFile( argv[1] );
  42109.     else    
  42110.         DigestString();
  42111.  
  42112. }
  42113.  
  42114. /*
  42115.     I use the 'chunk' method for processing files not because of
  42116.     limitations of my dll, but think what would happen if you
  42117.     tried to load an entire cd image into memory.
  42118. */
  42119. void DigestFile( char *szFName )
  42120. {
  42121.     FILE *file;
  42122.     void *lpData;
  42123.     long flen, mlen;
  42124.     MDxSum mdDataSum;
  42125.     MDxSum md4DataSum;
  42126.  
  42127.     // the 64 is for padding purposes
  42128.     lpData = malloc( READLEN + 64 );
  42129.     
  42130.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  42131.  
  42132.     file = fopen( szFName, "rb" );
  42133.     if( file == NULL )
  42134.     {
  42135.         printf("ERROR: File not found.\n");
  42136.         return;
  42137.     }
  42138.     
  42139.     MDxInit( &mdDataSum );
  42140.     MDxInit( &md4DataSum );
  42141.     
  42142.     fseek( file, 0, SEEK_END );
  42143.     //Get the file length
  42144.     flen = mlen = ftell( file );
  42145.     fseek( file, 0, SEEK_SET );
  42146.     
  42147.     // When it takes a while to process a large file,
  42148.     // remember that for each chunk it has to run 
  42149.     // through the main translation loop 16384 times!
  42150.         
  42151.     printf("Processing %ld byte file: .", flen );
  42152.     
  42153.     while( flen > READLEN )
  42154.     {
  42155.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42156.         {
  42157.             printf("READ ERROR!\n");
  42158.             return;
  42159.         }
  42160.         MD5Translate( lpData, READLEN, &mdDataSum );
  42161.         MD4Translate( lpData, READLEN, &md4DataSum );
  42162.         flen -= READLEN;
  42163.         printf(".");
  42164.     }
  42165.  
  42166.     if (fread( lpData, 1, flen, file ) != flen)
  42167.     {
  42168.         printf("READ ERROR!\n");
  42169.         return;
  42170.     }
  42171.     // This is why I added the new argument to MDxPad
  42172.     // So we can pass the length of the data AND the
  42173.     // Total length of the message
  42174.     // Also it now returns the # of padding bytes added,
  42175.     // this is for files that are an exact multiple of the chunk
  42176.     // length. (Otherwise the padding isn't Translated)
  42177.     flen += MDxPad( lpData, flen, mlen );
  42178.     MD5Translate( lpData, flen, &mdDataSum );    
  42179.     MD4Translate( lpData, flen, &md4DataSum );
  42180.  
  42181.     // New step necessary because of the 'chunking' method
  42182.     MDxFinalize( &mdDataSum );
  42183.     MDxFinalize( &md4DataSum );
  42184.     
  42185.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42186.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42187.     fclose(file);
  42188.         
  42189. }
  42190.  
  42191. void DigestString()
  42192. {
  42193.     
  42194.     //For our demo purposes, no strings bigger than 1024 :)
  42195.     unsigned char lpData[1024] = "";
  42196.     long len = 0;
  42197.     MDxSum mdDataSum;
  42198.  
  42199.     printf("Enter the string to digest: ");
  42200.     scanf("%s", &lpData );
  42201.     len = strlen(lpData);
  42202.     
  42203.     // Have to do this before the Padding...well...it's best anyway;)
  42204.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42205.     
  42206.     // For the strings, we're gonna pad and digest the string
  42207.     // in one pass.
  42208.     MDxInit( &mdDataSum );
  42209.     MDxPad( lpData, len, len );
  42210.     
  42211.     MD5Translate( lpData, len, &mdDataSum );
  42212.         // New step necessary because of the 'chunking' method
  42213.         MDxFinalize( &mdDataSum );
  42214.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42215.     
  42216.     MDxInit( &mdDataSum );
  42217.     MD4Translate( lpData, len, &mdDataSum );    
  42218.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42219.  
  42220.     return;
  42221. }
  42222.  
  42223.  
  42224. -------------- Include
  42225.  
  42226. #ifndef __windows_h__
  42227.         typedef unsigned long DWORD;
  42228.         #define STDCALL _stdcall
  42229. #endif
  42230.  
  42231. typedef struct 
  42232. {
  42233.     DWORD dwSum[4];
  42234. }MDxSum;
  42235.  
  42236. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  42237. void STDCALL MDxInit( MDxSum * );
  42238. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  42239. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  42240. const char * STDCALL MDxGetVersion();
  42241. void STDCALL MDxFinalize( MDxSum * );
  42242.  
  42243.  
  42244.  
  42245. #include "mdx.h"
  42246. #include <stdlib.h>
  42247. #include <stdio.h>
  42248. #include <string.h>
  42249.  
  42250. // READLEN % 64 must = 0
  42251. #define READLEN    1048576L // 2^20, 1MB
  42252.  
  42253. void DigestFile( char * );
  42254. void DigestString();
  42255.  
  42256. void main(int argc, char *argv[])
  42257. {
  42258.     printf("%s\n\n", MDxGetVersion());
  42259.  
  42260.     if( argc > 1 )
  42261.         DigestFile( argv[1] );
  42262.     else    
  42263.         DigestString();
  42264.  
  42265. }
  42266.  
  42267. /*
  42268.     I use the 'chunk' method for processing files not because of
  42269.     limitations of my dll, but think what would happen if you
  42270.     tried to load an entire cd image into memory.
  42271. */
  42272. void DigestFile( char *szFName )
  42273. {
  42274.     FILE *file;
  42275.     void *lpData;
  42276.     long flen, mlen;
  42277.     MDxSum mdDataSum;
  42278.     MDxSum md4DataSum;
  42279.  
  42280.     // the 64 is for padding purposes
  42281.     lpData = malloc( READLEN + 64 );
  42282.     
  42283.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  42284.  
  42285.     file = fopen( szFName, "rb" );
  42286.     if( file == NULL )
  42287.     {
  42288.         printf("ERROR: File not found.\n");
  42289.         return;
  42290.     }
  42291.     
  42292.     MDxInit( &mdDataSum );
  42293.     MDxInit( &md4DataSum );
  42294.     
  42295.     fseek( file, 0, SEEK_END );
  42296.     //Get the file length
  42297.     flen = mlen = ftell( file );
  42298.     fseek( file, 0, SEEK_SET );
  42299.     
  42300.     // When it takes a while to process a large file,
  42301.     // remember that for each chunk it has to run 
  42302.     // through the main translation loop 16384 times!
  42303.         
  42304.     printf("Processing %ld byte file: .", flen );
  42305.     
  42306.     while( flen > READLEN )
  42307.     {
  42308.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42309.         {
  42310.             printf("READ ERROR!\n");
  42311.             return;
  42312.         }
  42313.         MD5Translate( lpData, READLEN, &mdDataSum );
  42314.         MD4Translate( lpData, READLEN, &md4DataSum );
  42315.         flen -= READLEN;
  42316.         printf(".");
  42317.     }
  42318.  
  42319.     if (fread( lpData, 1, flen, file ) != flen)
  42320.     {
  42321.         printf("READ ERROR!\n");
  42322.         return;
  42323.     }
  42324.     // This is why I added the new argument to MDxPad
  42325.     // So we can pass the length of the data AND the
  42326.     // Total length of the message
  42327.     // Also it now returns the # of padding bytes added,
  42328.     // this is for files that are an exact multiple of the chunk
  42329.     // length. (Otherwise the padding isn't Translated)
  42330.     flen += MDxPad( lpData, flen, mlen );
  42331.     MD5Translate( lpData, flen, &mdDataSum );    
  42332.     MD4Translate( lpData, flen, &md4DataSum );
  42333.  
  42334.     // New step necessary because of the 'chunking' method
  42335.     MDxFinalize( &mdDataSum );
  42336.     MDxFinalize( &md4DataSum );
  42337.     
  42338.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42339.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42340.     fclose(file);
  42341.         
  42342. }
  42343.  
  42344. void DigestString()
  42345. {
  42346.     
  42347.     //For our demo purposes, no strings bigger than 1024 :)
  42348.     unsigned char lpData[1024] = "";
  42349.     long len = 0;
  42350.     MDxSum mdDataSum;
  42351.  
  42352.     printf("Enter the string to digest: ");
  42353.     scanf("%s", &lpData );
  42354.     len = strlen(lpData);
  42355.     
  42356.     // Have to do this before the Padding...well...it's best anyway;)
  42357.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42358.     
  42359.     // For the strings, we're gonna pad and digest the string
  42360.     // in one pass.
  42361.     MDxInit( &mdDataSum );
  42362.     MDxPad( lpData, len, len );
  42363.     
  42364.     MD5Translate( lpData, len, &mdDataSum );
  42365.         // New step necessary because of the 'chunking' method
  42366.         MDxFinalize( &mdDataSum );
  42367.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42368.     
  42369.     MDxInit( &mdDataSum );
  42370.     MD4Translate( lpData, len, &mdDataSum );    
  42371.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42372.  
  42373.     return;
  42374. }
  42375.  
  42376.  
  42377. -------------- Include
  42378.  
  42379. #ifndef __windows_h__
  42380.         typedef unsigned long DWORD;
  42381.         #define STDCALL _stdcall
  42382. #endif
  42383.  
  42384. typedef struct 
  42385. {
  42386.     DWORD dwSum[4];
  42387. }MDxSum;
  42388.  
  42389. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  42390. void STDCALL MDxInit( MDxSum * );
  42391. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  42392. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  42393. const char * STDCALL MDxGetVersion();
  42394. void STDCALL MDxFinalize( MDxSum * );
  42395.  
  42396.  
  42397.  
  42398.  
  42399. #include "mdx.h"
  42400. #include <stdlib.h>
  42401. #include <stdio.h>
  42402. #include <string.h>
  42403.  
  42404. // READLEN % 64 must = 0
  42405. #define READLEN    1048576L // 2^20, 1MB
  42406.  
  42407. void DigestFile( char * );
  42408. void DigestString();
  42409.  
  42410. void main(int argc, char *argv[])
  42411. {
  42412.     printf("%s\n\n", MDxGetVersion());
  42413.  
  42414.     if( argc > 1 )
  42415.         DigestFile( argv[1] );
  42416.     else    
  42417.         DigestString();
  42418.  
  42419. }
  42420.  
  42421. /*
  42422.     I use the 'chunk' method for processing files not because of
  42423.     limitations of my dll, but think what would happen if you
  42424.     tried to load an entire cd image into memory.
  42425. */
  42426. void DigestFile( char *szFName )
  42427. {
  42428.     FILE *file;
  42429.     void *lpData;
  42430.     long flen, mlen;
  42431.     MDxSum mdDataSum;
  42432.     MDxSum md4DataSum;
  42433.  
  42434.     // the 64 is for padding purposes
  42435.     lpData = malloc( READLEN + 64 );
  42436.     
  42437.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  42438.  
  42439.     file = fopen( szFName, "rb" );
  42440.     if( file == NULL )
  42441.     {
  42442.         printf("ERROR: File not found.\n");
  42443.         return;
  42444.     }
  42445.     
  42446.     MDxInit( &mdDataSum );
  42447.     MDxInit( &md4DataSum );
  42448.     
  42449.     fseek( file, 0, SEEK_END );
  42450.     //Get the file length
  42451.     flen = mlen = ftell( file );
  42452.     fseek( file, 0, SEEK_SET );
  42453.     
  42454.     // When it takes a while to process a large file,
  42455.     // remember that for each chunk it has to run 
  42456.     // through the main translation loop 16384 times!
  42457.         
  42458.     printf("Processing %ld byte file: .", flen );
  42459.     
  42460.     while( flen > READLEN )
  42461.     {
  42462.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42463.         {
  42464.             printf("READ ERROR!\n");
  42465.             return;
  42466.         }
  42467.         MD5Translate( lpData, READLEN, &mdDataSum );
  42468.         MD4Translate( lpData, READLEN, &md4DataSum );
  42469.         flen -= READLEN;
  42470.         printf(".");
  42471.     }
  42472.  
  42473.     if (fread( lpData, 1, flen, file ) != flen)
  42474.     {
  42475.         printf("READ ERROR!\n");
  42476.         return;
  42477.     }
  42478.     // This is why I added the new argument to MDxPad
  42479.     // So we can pass the length of the data AND the
  42480.     // Total length of the message
  42481.     // Also it now returns the # of padding bytes added,
  42482.     // this is for files that are an exact multiple of the chunk
  42483.     // length. (Otherwise the padding isn't Translated)
  42484.     flen += MDxPad( lpData, flen, mlen );
  42485.     MD5Translate( lpData, flen, &mdDataSum );    
  42486.     MD4Translate( lpData, flen, &md4DataSum );
  42487.  
  42488.     // New step necessary because of the 'chunking' method
  42489.     MDxFinalize( &mdDataSum );
  42490.     MDxFinalize( &md4DataSum );
  42491.     
  42492.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42493.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42494.     fclose(file);
  42495.         
  42496. }
  42497.  
  42498. void DigestString()
  42499. {
  42500.     
  42501.     //For our demo purposes, no strings bigger than 1024 :)
  42502.     unsigned char lpData[1024] = "";
  42503.     long len = 0;
  42504.     MDxSum mdDataSum;
  42505.  
  42506.     printf("Enter the string to digest: ");
  42507.     scanf("%s", &lpData );
  42508.     len = strlen(lpData);
  42509.     
  42510.     // Have to do this before the Padding...well...it's best anyway;)
  42511.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42512.     
  42513.     // For the strings, we're gonna pad and digest the string
  42514.     // in one pass.
  42515.     MDxInit( &mdDataSum );
  42516.     MDxPad( lpData, len, len );
  42517.     
  42518.     MD5Translate( lpData, len, &mdDataSum );
  42519.         // New step necessary because of the 'chunking' method
  42520.         MDxFinalize( &mdDataSum );
  42521.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42522.     
  42523.     MDxInit( &mdDataSum );
  42524.     MD4Translate( lpData, len, &mdDataSum );    
  42525.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42526.  
  42527.     return;
  42528. }
  42529.  
  42530.  
  42531. -------------- Include
  42532.  
  42533. #ifndef __windows_h__
  42534.         typedef unsigned long DWORD;
  42535.         #define STDCALL _stdcall
  42536. #endif
  42537.  
  42538. typedef struct 
  42539. {
  42540.     DWORD dwSum[4];
  42541. }MDxSum;
  42542.  
  42543. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  42544. void STDCALL MDxInit( MDxSum * );
  42545. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  42546. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  42547. const char * STDCALL MDxGetVersion();
  42548. void STDCALL MDxFinalize( MDxSum * );
  42549.  
  42550.  
  42551.  
  42552.  
  42553. #include "mdx.h"
  42554. #include <stdlib.h>
  42555. #include <stdio.h>
  42556. #include <string.h>
  42557.  
  42558. // READLEN % 64 must = 0
  42559. #define READLEN    1048576L // 2^20, 1MB
  42560.  
  42561. void DigestFile( char * );
  42562. void DigestString();
  42563.  
  42564. void main(int argc, char *argv[])
  42565. {
  42566.     printf("%s\n\n", MDxGetVersion());
  42567.  
  42568.     if( argc > 1 )
  42569.         DigestFile( argv[1] );
  42570.     else    
  42571.         DigestString();
  42572.  
  42573. }
  42574.  
  42575. /*
  42576.     I use the 'chunk' method for processing files not because of
  42577.     limitations of my dll, but think what would happen if you
  42578.     tried to load an entire cd image into memory.
  42579. */
  42580. void DigestFile( char *szFName )
  42581. {
  42582.     FILE *file;
  42583.     void *lpData;
  42584.     long flen, mlen;
  42585.     MDxSum mdDataSum;
  42586.     MDxSum md4DataSum;
  42587.  
  42588.     // the 64 is for padding purposes
  42589.     lpData = malloc( READLEN + 64 );
  42590.     
  42591.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  42592.  
  42593.     file = fopen( szFName, "rb" );
  42594.     if( file == NULL )
  42595.     {
  42596.         printf("ERROR: File not found.\n");
  42597.         return;
  42598.     }
  42599.     
  42600.     MDxInit( &mdDataSum );
  42601.     MDxInit( &md4DataSum );
  42602.     
  42603.     fseek( file, 0, SEEK_END );
  42604.     //Get the file length
  42605.     flen = mlen = ftell( file );
  42606.     fseek( file, 0, SEEK_SET );
  42607.     
  42608.     // When it takes a while to process a large file,
  42609.     // remember that for each chunk it has to run 
  42610.     // through the main translation loop 16384 times!
  42611.         
  42612.     printf("Processing %ld byte file: .", flen );
  42613.     
  42614.     while( flen > READLEN )
  42615.     {
  42616.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42617.         {
  42618.             printf("READ ERROR!\n");
  42619.             return;
  42620.         }
  42621.         MD5Translate( lpData, READLEN, &mdDataSum );
  42622.         MD4Translate( lpData, READLEN, &md4DataSum );
  42623.         flen -= READLEN;
  42624.         printf(".");
  42625.     }
  42626.  
  42627.     if (fread( lpData, 1, flen, file ) != flen)
  42628.     {
  42629.         printf("READ ERROR!\n");
  42630.         return;
  42631.     }
  42632.     // This is why I added the new argument to MDxPad
  42633.     // So we can pass the length of the data AND the
  42634.     // Total length of the message
  42635.     // Also it now returns the # of padding bytes added,
  42636.     // this is for files that are an exact multiple of the chunk
  42637.     // length. (Otherwise the padding isn't Translated)
  42638.     flen += MDxPad( lpData, flen, mlen );
  42639.     MD5Translate( lpData, flen, &mdDataSum );    
  42640.     MD4Translate( lpData, flen, &md4DataSum );
  42641.  
  42642.     // New step necessary because of the 'chunking' method
  42643.     MDxFinalize( &mdDataSum );
  42644.     MDxFinalize( &md4DataSum );
  42645.     
  42646.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42647.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42648.     fclose(file);
  42649.         
  42650. }
  42651.  
  42652. void DigestString()
  42653. {
  42654.     
  42655.     //For our demo purposes, no strings bigger than 1024 :)
  42656.     unsigned char lpData[1024] = "";
  42657.     long len = 0;
  42658.     MDxSum mdDataSum;
  42659.  
  42660.     printf("Enter the string to digest: ");
  42661.     scanf("%s", &lpData );
  42662.     len = strlen(lpData);
  42663.     
  42664.     // Have to do this before the Padding...well...it's best anyway;)
  42665.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42666.     
  42667.     // For the strings, we're gonna pad and digest the string
  42668.     // in one pass.
  42669.     MDxInit( &mdDataSum );
  42670.     MDxPad( lpData, len, len );
  42671.     
  42672.     MD5Translate( lpData, len, &mdDataSum );
  42673.         // New step necessary because of the 'chunking' method
  42674.         MDxFinalize( &mdDataSum );
  42675.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42676.     
  42677.     MDxInit( &mdDataSum );
  42678.     MD4Translate( lpData, len, &mdDataSum );    
  42679.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42680.  
  42681.     return;
  42682. }
  42683.  
  42684.  
  42685. -------------- Include
  42686.  
  42687. #ifndef __windows_h__
  42688.         typedef unsigned long DWORD;
  42689.         #define STDCALL _stdcall
  42690. #endif
  42691.  
  42692. typedef struct 
  42693. {
  42694.     DWORD dwSum[4];
  42695. }MDxSum;
  42696.  
  42697. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  42698. void STDCALL MDxInit( MDxSum * );
  42699. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  42700. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  42701. const char * STDCALL MDxGetVersion();
  42702. void STDCALL MDxFinalize( MDxSum * );
  42703.  
  42704.  
  42705.  
  42706.  
  42707. #include "mdx.h"
  42708. #include <stdlib.h>
  42709. #include <stdio.h>
  42710. #include <string.h>
  42711.  
  42712. // READLEN % 64 must = 0
  42713. #define READLEN    1048576L // 2^20, 1MB
  42714.  
  42715. void DigestFile( char * );
  42716. void DigestString();
  42717.  
  42718. void main(int argc, char *argv[])
  42719. {
  42720.     printf("%s\n\n", MDxGetVersion());
  42721.  
  42722.     if( argc > 1 )
  42723.         DigestFile( argv[1] );
  42724.     else    
  42725.         DigestString();
  42726.  
  42727. }
  42728.  
  42729. /*
  42730.     I use the 'chunk' method for processing files not because of
  42731.     limitations of my dll, but think what would happen if you
  42732.     tried to load an entire cd image into memory.
  42733. */
  42734. void DigestFile( char *szFName )
  42735. {
  42736.     FILE *file;
  42737.     void *lpData;
  42738.     long flen, mlen;
  42739.     MDxSum mdDataSum;
  42740.     MDxSum md4DataSum;
  42741.  
  42742.     // the 64 is for padding purposes
  42743.     lpData = malloc( READLEN + 64 );
  42744.     
  42745.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  42746.  
  42747.     file = fopen( szFName, "rb" );
  42748.     if( file == NULL )
  42749.     {
  42750.         printf("ERROR: File not found.\n");
  42751.         return;
  42752.     }
  42753.     
  42754.     MDxInit( &mdDataSum );
  42755.     MDxInit( &md4DataSum );
  42756.     
  42757.     fseek( file, 0, SEEK_END );
  42758.     //Get the file length
  42759.     flen = mlen = ftell( file );
  42760.     fseek( file, 0, SEEK_SET );
  42761.     
  42762.     // When it takes a while to process a large file,
  42763.     // remember that for each chunk it has to run 
  42764.     // through the main translation loop 16384 times!
  42765.         
  42766.     printf("Processing %ld byte file: .", flen );
  42767.     
  42768.     while( flen > READLEN )
  42769.     {
  42770.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42771.         {
  42772.             printf("READ ERROR!\n");
  42773.             return;
  42774.         }
  42775.         MD5Translate( lpData, READLEN, &mdDataSum );
  42776.         MD4Translate( lpData, READLEN, &md4DataSum );
  42777.         flen -= READLEN;
  42778.         printf(".");
  42779.     }
  42780.  
  42781.     if (fread( lpData, 1, flen, file ) != flen)
  42782.     {
  42783.         printf("READ ERROR!\n");
  42784.         return;
  42785.     }
  42786.     // This is why I added the new argument to MDxPad
  42787.     // So we can pass the length of the data AND the
  42788.     // Total length of the message
  42789.     // Also it now returns the # of padding bytes added,
  42790.     // this is for files that are an exact multiple of the chunk
  42791.     // length. (Otherwise the padding isn't Translated)
  42792.     flen += MDxPad( lpData, flen, mlen );
  42793.     MD5Translate( lpData, flen, &mdDataSum );    
  42794.     MD4Translate( lpData, flen, &md4DataSum );
  42795.  
  42796.     // New step necessary because of the 'chunking' method
  42797.     MDxFinalize( &mdDataSum );
  42798.     MDxFinalize( &md4DataSum );
  42799.     
  42800.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42801.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42802.     fclose(file);
  42803.         
  42804. }
  42805.  
  42806. void DigestString()
  42807. {
  42808.     
  42809.     //For our demo purposes, no strings bigger than 1024 :)
  42810.     unsigned char lpData[1024] = "";
  42811.     long len = 0;
  42812.     MDxSum mdDataSum;
  42813.  
  42814.     printf("Enter the string to digest: ");
  42815.     scanf("%s", &lpData );
  42816.     len = strlen(lpData);
  42817.     
  42818.     // Have to do this before the Padding...well...it's best anyway;)
  42819.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42820.     
  42821.     // For the strings, we're gonna pad and digest the string
  42822.     // in one pass.
  42823.     MDxInit( &mdDataSum );
  42824.     MDxPad( lpData, len, len );
  42825.     
  42826.     MD5Translate( lpData, len, &mdDataSum );
  42827.         // New step necessary because of the 'chunking' method
  42828.         MDxFinalize( &mdDataSum );
  42829.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42830.     
  42831.     MDxInit( &mdDataSum );
  42832.     MD4Translate( lpData, len, &mdDataSum );    
  42833.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42834.  
  42835.     return;
  42836. }
  42837.  
  42838.  
  42839. -------------- Include
  42840.  
  42841. #ifndef __windows_h__
  42842.         typedef unsigned long DWORD;
  42843.         #define STDCALL _stdcall
  42844. #endif
  42845.  
  42846. typedef struct 
  42847. {
  42848.     DWORD dwSum[4];
  42849. }MDxSum;
  42850.  
  42851. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  42852. void STDCALL MDxInit( MDxSum * );
  42853. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  42854. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  42855. const char * STDCALL MDxGetVersion();
  42856. void STDCALL MDxFinalize( MDxSum * );
  42857.  
  42858.  
  42859.  
  42860. #include "mdx.h"
  42861. #include <stdlib.h>
  42862. #include <stdio.h>
  42863. #include <string.h>
  42864.  
  42865. // READLEN % 64 must = 0
  42866. #define READLEN    1048576L // 2^20, 1MB
  42867.  
  42868. void DigestFile( char * );
  42869. void DigestString();
  42870.  
  42871. void main(int argc, char *argv[])
  42872. {
  42873.     printf("%s\n\n", MDxGetVersion());
  42874.  
  42875.     if( argc > 1 )
  42876.         DigestFile( argv[1] );
  42877.     else    
  42878.         DigestString();
  42879.  
  42880. }
  42881.  
  42882. /*
  42883.     I use the 'chunk' method for processing files not because of
  42884.     limitations of my dll, but think what would happen if you
  42885.     tried to load an entire cd image into memory.
  42886. */
  42887. void DigestFile( char *szFName )
  42888. {
  42889.     FILE *file;
  42890.     void *lpData;
  42891.     long flen, mlen;
  42892.     MDxSum mdDataSum;
  42893.     MDxSum md4DataSum;
  42894.  
  42895.     // the 64 is for padding purposes
  42896.     lpData = malloc( READLEN + 64 );
  42897.     
  42898.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  42899.  
  42900.     file = fopen( szFName, "rb" );
  42901.     if( file == NULL )
  42902.     {
  42903.         printf("ERROR: File not found.\n");
  42904.         return;
  42905.     }
  42906.     
  42907.     MDxInit( &mdDataSum );
  42908.     MDxInit( &md4DataSum );
  42909.     
  42910.     fseek( file, 0, SEEK_END );
  42911.     //Get the file length
  42912.     flen = mlen = ftell( file );
  42913.     fseek( file, 0, SEEK_SET );
  42914.     
  42915.     // When it takes a while to process a large file,
  42916.     // remember that for each chunk it has to run 
  42917.     // through the main translation loop 16384 times!
  42918.         
  42919.     printf("Processing %ld byte file: .", flen );
  42920.     
  42921.     while( flen > READLEN )
  42922.     {
  42923.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  42924.         {
  42925.             printf("READ ERROR!\n");
  42926.             return;
  42927.         }
  42928.         MD5Translate( lpData, READLEN, &mdDataSum );
  42929.         MD4Translate( lpData, READLEN, &md4DataSum );
  42930.         flen -= READLEN;
  42931.         printf(".");
  42932.     }
  42933.  
  42934.     if (fread( lpData, 1, flen, file ) != flen)
  42935.     {
  42936.         printf("READ ERROR!\n");
  42937.         return;
  42938.     }
  42939.     // This is why I added the new argument to MDxPad
  42940.     // So we can pass the length of the data AND the
  42941.     // Total length of the message
  42942.     // Also it now returns the # of padding bytes added,
  42943.     // this is for files that are an exact multiple of the chunk
  42944.     // length. (Otherwise the padding isn't Translated)
  42945.     flen += MDxPad( lpData, flen, mlen );
  42946.     MD5Translate( lpData, flen, &mdDataSum );    
  42947.     MD4Translate( lpData, flen, &md4DataSum );
  42948.  
  42949.     // New step necessary because of the 'chunking' method
  42950.     MDxFinalize( &mdDataSum );
  42951.     MDxFinalize( &md4DataSum );
  42952.     
  42953.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  42954.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42955.     fclose(file);
  42956.         
  42957. }
  42958.  
  42959. void DigestString()
  42960. {
  42961.     
  42962.     //For our demo purposes, no strings bigger than 1024 :)
  42963.     unsigned char lpData[1024] = "";
  42964.     long len = 0;
  42965.     MDxSum mdDataSum;
  42966.  
  42967.     printf("Enter the string to digest: ");
  42968.     scanf("%s", &lpData );
  42969.     len = strlen(lpData);
  42970.     
  42971.     // Have to do this before the Padding...well...it's best anyway;)
  42972.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  42973.     
  42974.     // For the strings, we're gonna pad and digest the string
  42975.     // in one pass.
  42976.     MDxInit( &mdDataSum );
  42977.     MDxPad( lpData, len, len );
  42978.     
  42979.     MD5Translate( lpData, len, &mdDataSum );
  42980.         // New step necessary because of the 'chunking' method
  42981.         MDxFinalize( &mdDataSum );
  42982.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42983.     
  42984.     MDxInit( &mdDataSum );
  42985.     MD4Translate( lpData, len, &mdDataSum );    
  42986.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  42987.  
  42988.     return;
  42989. }
  42990.  
  42991.  
  42992. -------------- Include
  42993.  
  42994. #ifndef __windows_h__
  42995.         typedef unsigned long DWORD;
  42996.         #define STDCALL _stdcall
  42997. #endif
  42998.  
  42999. typedef struct 
  43000. {
  43001.     DWORD dwSum[4];
  43002. }MDxSum;
  43003.  
  43004. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43005. void STDCALL MDxInit( MDxSum * );
  43006. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43007. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43008. const char * STDCALL MDxGetVersion();
  43009. void STDCALL MDxFinalize( MDxSum * );
  43010.  
  43011.  
  43012.  
  43013. #include "mdx.h"
  43014. #include <stdlib.h>
  43015. #include <stdio.h>
  43016. #include <string.h>
  43017.  
  43018. // READLEN % 64 must = 0
  43019. #define READLEN    1048576L // 2^20, 1MB
  43020.  
  43021. void DigestFile( char * );
  43022. void DigestString();
  43023.  
  43024. void main(int argc, char *argv[])
  43025. {
  43026.     printf("%s\n\n", MDxGetVersion());
  43027.  
  43028.     if( argc > 1 )
  43029.         DigestFile( argv[1] );
  43030.     else    
  43031.         DigestString();
  43032.  
  43033. }
  43034.  
  43035. /*
  43036.     I use the 'chunk' method for processing files not because of
  43037.     limitations of my dll, but think what would happen if you
  43038.     tried to load an entire cd image into memory.
  43039. */
  43040. void DigestFile( char *szFName )
  43041. {
  43042.     FILE *file;
  43043.     void *lpData;
  43044.     long flen, mlen;
  43045.     MDxSum mdDataSum;
  43046.     MDxSum md4DataSum;
  43047.  
  43048.     // the 64 is for padding purposes
  43049.     lpData = malloc( READLEN + 64 );
  43050.     
  43051.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  43052.  
  43053.     file = fopen( szFName, "rb" );
  43054.     if( file == NULL )
  43055.     {
  43056.         printf("ERROR: File not found.\n");
  43057.         return;
  43058.     }
  43059.     
  43060.     MDxInit( &mdDataSum );
  43061.     MDxInit( &md4DataSum );
  43062.     
  43063.     fseek( file, 0, SEEK_END );
  43064.     //Get the file length
  43065.     flen = mlen = ftell( file );
  43066.     fseek( file, 0, SEEK_SET );
  43067.     
  43068.     // When it takes a while to process a large file,
  43069.     // remember that for each chunk it has to run 
  43070.     // through the main translation loop 16384 times!
  43071.         
  43072.     printf("Processing %ld byte file: .", flen );
  43073.     
  43074.     while( flen > READLEN )
  43075.     {
  43076.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  43077.         {
  43078.             printf("READ ERROR!\n");
  43079.             return;
  43080.         }
  43081.         MD5Translate( lpData, READLEN, &mdDataSum );
  43082.         MD4Translate( lpData, READLEN, &md4DataSum );
  43083.         flen -= READLEN;
  43084.         printf(".");
  43085.     }
  43086.  
  43087.     if (fread( lpData, 1, flen, file ) != flen)
  43088.     {
  43089.         printf("READ ERROR!\n");
  43090.         return;
  43091.     }
  43092.     // This is why I added the new argument to MDxPad
  43093.     // So we can pass the length of the data AND the
  43094.     // Total length of the message
  43095.     // Also it now returns the # of padding bytes added,
  43096.     // this is for files that are an exact multiple of the chunk
  43097.     // length. (Otherwise the padding isn't Translated)
  43098.     flen += MDxPad( lpData, flen, mlen );
  43099.     MD5Translate( lpData, flen, &mdDataSum );    
  43100.     MD4Translate( lpData, flen, &md4DataSum );
  43101.  
  43102.     // New step necessary because of the 'chunking' method
  43103.     MDxFinalize( &mdDataSum );
  43104.     MDxFinalize( &md4DataSum );
  43105.     
  43106.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  43107.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43108.     fclose(file);
  43109.         
  43110. }
  43111.  
  43112. void DigestString()
  43113. {
  43114.     
  43115.     //For our demo purposes, no strings bigger than 1024 :)
  43116.     unsigned char lpData[1024] = "";
  43117.     long len = 0;
  43118.     MDxSum mdDataSum;
  43119.  
  43120.     printf("Enter the string to digest: ");
  43121.     scanf("%s", &lpData );
  43122.     len = strlen(lpData);
  43123.     
  43124.     // Have to do this before the Padding...well...it's best anyway;)
  43125.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  43126.     
  43127.     // For the strings, we're gonna pad and digest the string
  43128.     // in one pass.
  43129.     MDxInit( &mdDataSum );
  43130.     MDxPad( lpData, len, len );
  43131.     
  43132.     MD5Translate( lpData, len, &mdDataSum );
  43133.         // New step necessary because of the 'chunking' method
  43134.         MDxFinalize( &mdDataSum );
  43135.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43136.     
  43137.     MDxInit( &mdDataSum );
  43138.     MD4Translate( lpData, len, &mdDataSum );    
  43139.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43140.  
  43141.     return;
  43142. }
  43143.  
  43144.  
  43145. -------------- Include
  43146.  
  43147. #ifndef __windows_h__
  43148.         typedef unsigned long DWORD;
  43149.         #define STDCALL _stdcall
  43150. #endif
  43151.  
  43152. typedef struct 
  43153. {
  43154.     DWORD dwSum[4];
  43155. }MDxSum;
  43156.  
  43157. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43158. void STDCALL MDxInit( MDxSum * );
  43159. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43160. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43161. const char * STDCALL MDxGetVersion();
  43162. void STDCALL MDxFinalize( MDxSum * );
  43163.  
  43164.  
  43165.  
  43166.  
  43167. #include "mdx.h"
  43168. #include <stdlib.h>
  43169. #include <stdio.h>
  43170. #include <string.h>
  43171.  
  43172. // READLEN % 64 must = 0
  43173. #define READLEN    1048576L // 2^20, 1MB
  43174.  
  43175. void DigestFile( char * );
  43176. void DigestString();
  43177.  
  43178. void main(int argc, char *argv[])
  43179. {
  43180.     printf("%s\n\n", MDxGetVersion());
  43181.  
  43182.     if( argc > 1 )
  43183.         DigestFile( argv[1] );
  43184.     else    
  43185.         DigestString();
  43186.  
  43187. }
  43188.  
  43189. /*
  43190.     I use the 'chunk' method for processing files not because of
  43191.     limitations of my dll, but think what would happen if you
  43192.     tried to load an entire cd image into memory.
  43193. */
  43194. void DigestFile( char *szFName )
  43195. {
  43196.     FILE *file;
  43197.     void *lpData;
  43198.     long flen, mlen;
  43199.     MDxSum mdDataSum;
  43200.     MDxSum md4DataSum;
  43201.  
  43202.     // the 64 is for padding purposes
  43203.     lpData = malloc( READLEN + 64 );
  43204.     
  43205.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  43206.  
  43207.     file = fopen( szFName, "rb" );
  43208.     if( file == NULL )
  43209.     {
  43210.         printf("ERROR: File not found.\n");
  43211.         return;
  43212.     }
  43213.     
  43214.     MDxInit( &mdDataSum );
  43215.     MDxInit( &md4DataSum );
  43216.     
  43217.     fseek( file, 0, SEEK_END );
  43218.     //Get the file length
  43219.     flen = mlen = ftell( file );
  43220.     fseek( file, 0, SEEK_SET );
  43221.     
  43222.     // When it takes a while to process a large file,
  43223.     // remember that for each chunk it has to run 
  43224.     // through the main translation loop 16384 times!
  43225.         
  43226.     printf("Processing %ld byte file: .", flen );
  43227.     
  43228.     while( flen > READLEN )
  43229.     {
  43230.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  43231.         {
  43232.             printf("READ ERROR!\n");
  43233.             return;
  43234.         }
  43235.         MD5Translate( lpData, READLEN, &mdDataSum );
  43236.         MD4Translate( lpData, READLEN, &md4DataSum );
  43237.         flen -= READLEN;
  43238.         printf(".");
  43239.     }
  43240.  
  43241.     if (fread( lpData, 1, flen, file ) != flen)
  43242.     {
  43243.         printf("READ ERROR!\n");
  43244.         return;
  43245.     }
  43246.     // This is why I added the new argument to MDxPad
  43247.     // So we can pass the length of the data AND the
  43248.     // Total length of the message
  43249.     // Also it now returns the # of padding bytes added,
  43250.     // this is for files that are an exact multiple of the chunk
  43251.     // length. (Otherwise the padding isn't Translated)
  43252.     flen += MDxPad( lpData, flen, mlen );
  43253.     MD5Translate( lpData, flen, &mdDataSum );    
  43254.     MD4Translate( lpData, flen, &md4DataSum );
  43255.  
  43256.     // New step necessary because of the 'chunking' method
  43257.     MDxFinalize( &mdDataSum );
  43258.     MDxFinalize( &md4DataSum );
  43259.     
  43260.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  43261.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43262.     fclose(file);
  43263.         
  43264. }
  43265.  
  43266. void DigestString()
  43267. {
  43268.     
  43269.     //For our demo purposes, no strings bigger than 1024 :)
  43270.     unsigned char lpData[1024] = "";
  43271.     long len = 0;
  43272.     MDxSum mdDataSum;
  43273.  
  43274.     printf("Enter the string to digest: ");
  43275.     scanf("%s", &lpData );
  43276.     len = strlen(lpData);
  43277.     
  43278.     // Have to do this before the Padding...well...it's best anyway;)
  43279.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  43280.     
  43281.     // For the strings, we're gonna pad and digest the string
  43282.     // in one pass.
  43283.     MDxInit( &mdDataSum );
  43284.     MDxPad( lpData, len, len );
  43285.     
  43286.     MD5Translate( lpData, len, &mdDataSum );
  43287.         // New step necessary because of the 'chunking' method
  43288.         MDxFinalize( &mdDataSum );
  43289.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43290.     
  43291.     MDxInit( &mdDataSum );
  43292.     MD4Translate( lpData, len, &mdDataSum );    
  43293.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43294.  
  43295.     return;
  43296. }
  43297.  
  43298.  
  43299. -------------- Include
  43300.  
  43301. #ifndef __windows_h__
  43302.         typedef unsigned long DWORD;
  43303.         #define STDCALL _stdcall
  43304. #endif
  43305.  
  43306. typedef struct 
  43307. {
  43308.     DWORD dwSum[4];
  43309. }MDxSum;
  43310.  
  43311. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43312. void STDCALL MDxInit( MDxSum * );
  43313. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43314. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43315. const char * STDCALL MDxGetVersion();
  43316. void STDCALL MDxFinalize( MDxSum * );
  43317.  
  43318.  
  43319.  
  43320.  
  43321. #include "mdx.h"
  43322. #include <stdlib.h>
  43323. #include <stdio.h>
  43324. #include <string.h>
  43325.  
  43326. // READLEN % 64 must = 0
  43327. #define READLEN    1048576L // 2^20, 1MB
  43328.  
  43329. void DigestFile( char * );
  43330. void DigestString();
  43331.  
  43332. void main(int argc, char *argv[])
  43333. {
  43334.     printf("%s\n\n", MDxGetVersion());
  43335.  
  43336.     if( argc > 1 )
  43337.         DigestFile( argv[1] );
  43338.     else    
  43339.         DigestString();
  43340.  
  43341. }
  43342.  
  43343. /*
  43344.     I use the 'chunk' method for processing files not because of
  43345.     limitations of my dll, but think what would happen if you
  43346.     tried to load an entire cd image into memory.
  43347. */
  43348. void DigestFile( char *szFName )
  43349. {
  43350.     FILE *file;
  43351.     void *lpData;
  43352.     long flen, mlen;
  43353.     MDxSum mdDataSum;
  43354.     MDxSum md4DataSum;
  43355.  
  43356.     // the 64 is for padding purposes
  43357.     lpData = malloc( READLEN + 64 );
  43358.     
  43359.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  43360.  
  43361.     file = fopen( szFName, "rb" );
  43362.     if( file == NULL )
  43363.     {
  43364.         printf("ERROR: File not found.\n");
  43365.         return;
  43366.     }
  43367.     
  43368.     MDxInit( &mdDataSum );
  43369.     MDxInit( &md4DataSum );
  43370.     
  43371.     fseek( file, 0, SEEK_END );
  43372.     //Get the file length
  43373.     flen = mlen = ftell( file );
  43374.     fseek( file, 0, SEEK_SET );
  43375.     
  43376.     // When it takes a while to process a large file,
  43377.     // remember that for each chunk it has to run 
  43378.     // through the main translation loop 16384 times!
  43379.         
  43380.     printf("Processing %ld byte file: .", flen );
  43381.     
  43382.     while( flen > READLEN )
  43383.     {
  43384.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  43385.         {
  43386.             printf("READ ERROR!\n");
  43387.             return;
  43388.         }
  43389.         MD5Translate( lpData, READLEN, &mdDataSum );
  43390.         MD4Translate( lpData, READLEN, &md4DataSum );
  43391.         flen -= READLEN;
  43392.         printf(".");
  43393.     }
  43394.  
  43395.     if (fread( lpData, 1, flen, file ) != flen)
  43396.     {
  43397.         printf("READ ERROR!\n");
  43398.         return;
  43399.     }
  43400.     // This is why I added the new argument to MDxPad
  43401.     // So we can pass the length of the data AND the
  43402.     // Total length of the message
  43403.     // Also it now returns the # of padding bytes added,
  43404.     // this is for files that are an exact multiple of the chunk
  43405.     // length. (Otherwise the padding isn't Translated)
  43406.     flen += MDxPad( lpData, flen, mlen );
  43407.     MD5Translate( lpData, flen, &mdDataSum );    
  43408.     MD4Translate( lpData, flen, &md4DataSum );
  43409.  
  43410.     // New step necessary because of the 'chunking' method
  43411.     MDxFinalize( &mdDataSum );
  43412.     MDxFinalize( &md4DataSum );
  43413.     
  43414.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  43415.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43416.     fclose(file);
  43417.         
  43418. }
  43419.  
  43420. void DigestString()
  43421. {
  43422.     
  43423.     //For our demo purposes, no strings bigger than 1024 :)
  43424.     unsigned char lpData[1024] = "";
  43425.     long len = 0;
  43426.     MDxSum mdDataSum;
  43427.  
  43428.     printf("Enter the string to digest: ");
  43429.     scanf("%s", &lpData );
  43430.     len = strlen(lpData);
  43431.     
  43432.     // Have to do this before the Padding...well...it's best anyway;)
  43433.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  43434.     
  43435.     // For the strings, we're gonna pad and digest the string
  43436.     // in one pass.
  43437.     MDxInit( &mdDataSum );
  43438.     MDxPad( lpData, len, len );
  43439.     
  43440.     MD5Translate( lpData, len, &mdDataSum );
  43441.         // New step necessary because of the 'chunking' method
  43442.         MDxFinalize( &mdDataSum );
  43443.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43444.     
  43445.     MDxInit( &mdDataSum );
  43446.     MD4Translate( lpData, len, &mdDataSum );    
  43447.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43448.  
  43449.     return;
  43450. }
  43451.  
  43452.  
  43453. -------------- Include
  43454.  
  43455. #ifndef __windows_h__
  43456.         typedef unsigned long DWORD;
  43457.         #define STDCALL _stdcall
  43458. #endif
  43459.  
  43460. typedef struct 
  43461. {
  43462.     DWORD dwSum[4];
  43463. }MDxSum;
  43464.  
  43465. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43466. void STDCALL MDxInit( MDxSum * );
  43467. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43468. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43469. const char * STDCALL MDxGetVersion();
  43470. void STDCALL MDxFinalize( MDxSum * );
  43471.  
  43472.  
  43473.  
  43474.  
  43475. #include "mdx.h"
  43476. #include <stdlib.h>
  43477. #include <stdio.h>
  43478. #include <string.h>
  43479.  
  43480. // READLEN % 64 must = 0
  43481. #define READLEN    1048576L // 2^20, 1MB
  43482.  
  43483. void DigestFile( char * );
  43484. void DigestString();
  43485.  
  43486. void main(int argc, char *argv[])
  43487. {
  43488.     printf("%s\n\n", MDxGetVersion());
  43489.  
  43490.     if( argc > 1 )
  43491.         DigestFile( argv[1] );
  43492.     else    
  43493.         DigestString();
  43494.  
  43495. }
  43496.  
  43497. /*
  43498.     I use the 'chunk' method for processing files not because of
  43499.     limitations of my dll, but think what would happen if you
  43500.     tried to load an entire cd image into memory.
  43501. */
  43502. void DigestFile( char *szFName )
  43503. {
  43504.     FILE *file;
  43505.     void *lpData;
  43506.     long flen, mlen;
  43507.     MDxSum mdDataSum;
  43508.     MDxSum md4DataSum;
  43509.  
  43510.     // the 64 is for padding purposes
  43511.     lpData = malloc( READLEN + 64 );
  43512.     
  43513.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  43514.  
  43515.     file = fopen( szFName, "rb" );
  43516.     if( file == NULL )
  43517.     {
  43518.         printf("ERROR: File not found.\n");
  43519.         return;
  43520.     }
  43521.     
  43522.     MDxInit( &mdDataSum );
  43523.     MDxInit( &md4DataSum );
  43524.     
  43525.     fseek( file, 0, SEEK_END );
  43526.     //Get the file length
  43527.     flen = mlen = ftell( file );
  43528.     fseek( file, 0, SEEK_SET );
  43529.     
  43530.     // When it takes a while to process a large file,
  43531.     // remember that for each chunk it has to run 
  43532.     // through the main translation loop 16384 times!
  43533.         
  43534.     printf("Processing %ld byte file: .", flen );
  43535.     
  43536.     while( flen > READLEN )
  43537.     {
  43538.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  43539.         {
  43540.             printf("READ ERROR!\n");
  43541.             return;
  43542.         }
  43543.         MD5Translate( lpData, READLEN, &mdDataSum );
  43544.         MD4Translate( lpData, READLEN, &md4DataSum );
  43545.         flen -= READLEN;
  43546.         printf(".");
  43547.     }
  43548.  
  43549.     if (fread( lpData, 1, flen, file ) != flen)
  43550.     {
  43551.         printf("READ ERROR!\n");
  43552.         return;
  43553.     }
  43554.     // This is why I added the new argument to MDxPad
  43555.     // So we can pass the length of the data AND the
  43556.     // Total length of the message
  43557.     // Also it now returns the # of padding bytes added,
  43558.     // this is for files that are an exact multiple of the chunk
  43559.     // length. (Otherwise the padding isn't Translated)
  43560.     flen += MDxPad( lpData, flen, mlen );
  43561.     MD5Translate( lpData, flen, &mdDataSum );    
  43562.     MD4Translate( lpData, flen, &md4DataSum );
  43563.  
  43564.     // New step necessary because of the 'chunking' method
  43565.     MDxFinalize( &mdDataSum );
  43566.     MDxFinalize( &md4DataSum );
  43567.     
  43568.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  43569.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43570.     fclose(file);
  43571.         
  43572. }
  43573.  
  43574. void DigestString()
  43575. {
  43576.     
  43577.     //For our demo purposes, no strings bigger than 1024 :)
  43578.     unsigned char lpData[1024] = "";
  43579.     long len = 0;
  43580.     MDxSum mdDataSum;
  43581.  
  43582.     printf("Enter the string to digest: ");
  43583.     scanf("%s", &lpData );
  43584.     len = strlen(lpData);
  43585.     
  43586.     // Have to do this before the Padding...well...it's best anyway;)
  43587.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  43588.     
  43589.     // For the strings, we're gonna pad and digest the string
  43590.     // in one pass.
  43591.     MDxInit( &mdDataSum );
  43592.     MDxPad( lpData, len, len );
  43593.     
  43594.     MD5Translate( lpData, len, &mdDataSum );
  43595.         // New step necessary because of the 'chunking' method
  43596.         MDxFinalize( &mdDataSum );
  43597.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43598.     
  43599.     MDxInit( &mdDataSum );
  43600.     MD4Translate( lpData, len, &mdDataSum );    
  43601.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43602.  
  43603.     return;
  43604. }
  43605.  
  43606.  
  43607. -------------- Include
  43608.  
  43609. #ifndef __windows_h__
  43610.         typedef unsigned long DWORD;
  43611.         #define STDCALL _stdcall
  43612. #endif
  43613.  
  43614. typedef struct 
  43615. {
  43616.     DWORD dwSum[4];
  43617. }MDxSum;
  43618.  
  43619. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43620. void STDCALL MDxInit( MDxSum * );
  43621. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43622. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43623. const char * STDCALL MDxGetVersion();
  43624. void STDCALL MDxFinalize( MDxSum * );
  43625.  
  43626.  
  43627.  
  43628. #include "mdx.h"
  43629. #include <stdlib.h>
  43630. #include <stdio.h>
  43631. #include <string.h>
  43632.  
  43633. // READLEN % 64 must = 0
  43634. #define READLEN    1048576L // 2^20, 1MB
  43635.  
  43636. void DigestFile( char * );
  43637. void DigestString();
  43638.  
  43639. void main(int argc, char *argv[])
  43640. {
  43641.     printf("%s\n\n", MDxGetVersion());
  43642.  
  43643.     if( argc > 1 )
  43644.         DigestFile( argv[1] );
  43645.     else    
  43646.         DigestString();
  43647.  
  43648. }
  43649.  
  43650. /*
  43651.     I use the 'chunk' method for processing files not because of
  43652.     limitations of my dll, but think what would happen if you
  43653.     tried to load an entire cd image into memory.
  43654. */
  43655. void DigestFile( char *szFName )
  43656. {
  43657.     FILE *file;
  43658.     void *lpData;
  43659.     long flen, mlen;
  43660.     MDxSum mdDataSum;
  43661.     MDxSum md4DataSum;
  43662.  
  43663.     // the 64 is for padding purposes
  43664.     lpData = malloc( READLEN + 64 );
  43665.     
  43666.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  43667.  
  43668.     file = fopen( szFName, "rb" );
  43669.     if( file == NULL )
  43670.     {
  43671.         printf("ERROR: File not found.\n");
  43672.         return;
  43673.     }
  43674.     
  43675.     MDxInit( &mdDataSum );
  43676.     MDxInit( &md4DataSum );
  43677.     
  43678.     fseek( file, 0, SEEK_END );
  43679.     //Get the file length
  43680.     flen = mlen = ftell( file );
  43681.     fseek( file, 0, SEEK_SET );
  43682.     
  43683.     // When it takes a while to process a large file,
  43684.     // remember that for each chunk it has to run 
  43685.     // through the main translation loop 16384 times!
  43686.         
  43687.     printf("Processing %ld byte file: .", flen );
  43688.     
  43689.     while( flen > READLEN )
  43690.     {
  43691.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  43692.         {
  43693.             printf("READ ERROR!\n");
  43694.             return;
  43695.         }
  43696.         MD5Translate( lpData, READLEN, &mdDataSum );
  43697.         MD4Translate( lpData, READLEN, &md4DataSum );
  43698.         flen -= READLEN;
  43699.         printf(".");
  43700.     }
  43701.  
  43702.     if (fread( lpData, 1, flen, file ) != flen)
  43703.     {
  43704.         printf("READ ERROR!\n");
  43705.         return;
  43706.     }
  43707.     // This is why I added the new argument to MDxPad
  43708.     // So we can pass the length of the data AND the
  43709.     // Total length of the message
  43710.     // Also it now returns the # of padding bytes added,
  43711.     // this is for files that are an exact multiple of the chunk
  43712.     // length. (Otherwise the padding isn't Translated)
  43713.     flen += MDxPad( lpData, flen, mlen );
  43714.     MD5Translate( lpData, flen, &mdDataSum );    
  43715.     MD4Translate( lpData, flen, &md4DataSum );
  43716.  
  43717.     // New step necessary because of the 'chunking' method
  43718.     MDxFinalize( &mdDataSum );
  43719.     MDxFinalize( &md4DataSum );
  43720.     
  43721.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  43722.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43723.     fclose(file);
  43724.         
  43725. }
  43726.  
  43727. void DigestString()
  43728. {
  43729.     
  43730.     //For our demo purposes, no strings bigger than 1024 :)
  43731.     unsigned char lpData[1024] = "";
  43732.     long len = 0;
  43733.     MDxSum mdDataSum;
  43734.  
  43735.     printf("Enter the string to digest: ");
  43736.     scanf("%s", &lpData );
  43737.     len = strlen(lpData);
  43738.     
  43739.     // Have to do this before the Padding...well...it's best anyway;)
  43740.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  43741.     
  43742.     // For the strings, we're gonna pad and digest the string
  43743.     // in one pass.
  43744.     MDxInit( &mdDataSum );
  43745.     MDxPad( lpData, len, len );
  43746.     
  43747.     MD5Translate( lpData, len, &mdDataSum );
  43748.         // New step necessary because of the 'chunking' method
  43749.         MDxFinalize( &mdDataSum );
  43750.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43751.     
  43752.     MDxInit( &mdDataSum );
  43753.     MD4Translate( lpData, len, &mdDataSum );    
  43754.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43755.  
  43756.     return;
  43757. }
  43758.  
  43759.  
  43760. -------------- Include
  43761.  
  43762. #ifndef __windows_h__
  43763.         typedef unsigned long DWORD;
  43764.         #define STDCALL _stdcall
  43765. #endif
  43766.  
  43767. typedef struct 
  43768. {
  43769.     DWORD dwSum[4];
  43770. }MDxSum;
  43771.  
  43772. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43773. void STDCALL MDxInit( MDxSum * );
  43774. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43775. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43776. const char * STDCALL MDxGetVersion();
  43777. void STDCALL MDxFinalize( MDxSum * );
  43778.  
  43779.  
  43780.  
  43781. #include "mdx.h"
  43782. #include <stdlib.h>
  43783. #include <stdio.h>
  43784. #include <string.h>
  43785.  
  43786. // READLEN % 64 must = 0
  43787. #define READLEN    1048576L // 2^20, 1MB
  43788.  
  43789. void DigestFile( char * );
  43790. void DigestString();
  43791.  
  43792. void main(int argc, char *argv[])
  43793. {
  43794.     printf("%s
  43795. {
  43796.     
  43797.     //For our demo purposes, no strings bigger than 1024 :)
  43798.     unsigned char lpData[1024] = "";
  43799.     long len = 0;
  43800.     MDxSum mdDataSum;
  43801.  
  43802.     printf("Enter the string to digest: ");
  43803.     scanf("%s", &lpData );
  43804.     len = strlen(lpData);
  43805.     = strlen(lpData);
  43806.     = strlen(lpData);
  43807.     = strlen(lpData);
  43808.     = strlen(lpData);
  43809.     = strlen(lpData);
  43810.     = strlen(lpData);
  43811.     = strlen(lpData);
  43812.     = strlen(lpData);
  43813.     = strlen(lpData);
  43814.     = strlen(lpData);
  43815.     = strlen(lpData);Data) &mdDataSum );
  43816.     MDxInit( &md4DataSum );
  43817.     
  43818.     fseek( file, 0, SEEK_END );
  43819.     //Get the file length
  43820.     flen = mlen = ftell( file );
  43821.     fseek( file, 0, SEEK_SET );
  43822.     
  43823.     // When it takes a while to process a large file,
  43824.     // remember that for each chunth
  43825.     flen = ntf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43826.  
  43827.     return;
  43828. }
  43829.  
  43830.  
  43831. -------------- Include
  43832.  
  43833. #ifndef __windows_h__
  43834.         typedef unsigned long DWORD;
  43835.         #define STDCALL _stdcall
  43836. #eROR!\n");
  43837.             return;
  43838.         }
  43839.   
  43840.  
  43841.  
  43842. ---------ng DWORD;
  43843.         #define STDCALL _stdcall
  43844. #eROR!\n");
  43845.             return;
  43846.         }
  43847.   
  43848.  
  43849.  
  43850. ---------ng DWORD;
  43851.         #define STDCALL _stdcall
  43852. #eROR!\n");
  43853.             return;
  43854.         }
  43855.   
  43856.  
  43857.  
  43858. ---------ng DWORD;
  43859.         #define STDCALL _stdcall larSTDCALL _stdcall
  43860. #eROR!\n");
  43861.             return;
  43862.         }
  43863.   
  43864.  
  43865.  
  43866. ---------ng DWORD;
  43867.         #define STDCALL _stdcall larSTDCALL _stdcall
  43868. #eROR!\n");
  43869.             return;
  43870.         }
  43871.   
  43872.  
  43873.  
  43874. ---------ng DWORD;
  43875.         #define STDCALL _stdcall larSTTTTTTTTTTTTTTTTlong flen, mlen;
  43876.     MDxSum mdDataSum;
  43877.     MDxSum md4DataSum;
  43878.  
  43879.     // the 64 is for padding purposes
  43880.     lpData = malloc( READLEN + 64 );
  43881.     
  43882.     printf( "MD4/5 Digests of \"%s\":\n", szFName );
  43883.  
  43884.     file = fopen( szFName, "rb" );
  43885.     if( file ==     // remember that for each chunk it has to run 
  43886.     // through the main translation loop 16384 times!
  43887.         
  43888.     printf("Processing %ld byte file: .", flen );
  43889.     
  43890.     while( flen > READLEN )
  43891.     {
  43892.         if( fread( lpData, 1, READLEN, file ) != flen = mlen = ftell( file );
  43893.     fseek( file, 0, SEEK_SET );
  43894.     
  43895.     // When it takes a while to process a large file,
  43896.     // remember that for each chunk it has to run 
  43897.     // through the main translation loop 16384 times!
  43898.         
  43899.     printf("Processing %ld byte file: .", flen );
  43900.     
  43901.     while( flen > READLEN )
  43902.     {
  43903.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  43904.         {
  43905.             printf("READ ERROR!\n");
  43906.             return;
  43907.         }
  43908.         MD5Translate( lpData, READLEN, &mdDataSum );
  43909.         MD4Translate( lpData, READLEN, &md4DataSum );
  43910.         flen -= READLEN;
  43911.         printf(".");
  43912.     }
  43913.  
  43914.     if (fread( lpData, 1, flen, file ) != flen)
  43915.     {
  43916.         printf("READ ERROR!\n");
  43917.         return;
  43918.     }
  43919.     // This is why I added the new argument to MDxPad
  43920.     // So we can pass the length of the data AND the
  43921.     // Total length of the message
  43922.     // Also it now returns the # of padding bytes added,
  43923.     // this is for files that are an exact multiple of the chunk
  43924.     // length. (Otherwise the padding isn't Translated)
  43925.     flen += MDxPad( lpData, flen, mlen );
  43926.     MD5Translate( lpData, flen, &mdDataSum );    
  43927.     MD4Translate( lpData, flen, &md4DataSum );
  43928.  
  43929.     // New step necessary because of the 'chunking' method
  43930.     MDxFinalize( &mdDataSum );
  43931.     MDxFinalize( &md4DataSum );
  43932.     
  43933.     printf("\nMD4: %08x%08x%08x%08x\n", md4DataSum.dwSum[0], md4DataSum.dwSum[1], md4DataSum.dwSum[2], md4DataSum.dwSum[3]);
  43934.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43935.     fclose(file);
  43936.         
  43937. }
  43938.  
  43939. void DigestString()
  43940. {
  43941.     
  43942.     //For our demo purposes, no strings bigger than 1024 :)
  43943.     unsigned char lpData[1024] = "";
  43944.     long len = 0;
  43945.     MDxSum mdDataSum;
  43946.  
  43947.     printf("Enter the string to digest: ");
  43948.     scanf("%s", &lpData );
  43949.     len = strlen(lpData);
  43950.     
  43951.     // Have to do this before the Padding...well...it's best anyway;)
  43952.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  43953.     
  43954.     // For the strings, we're gonna pad and digest the string
  43955.     // in one pass.
  43956.     MDxInit( &mdDataSum );
  43957.     MDxPad( lpData, len, len );
  43958.     
  43959.     MD5Translate( lpData, len, &mdDataSum );
  43960.         // New step necessary because of the 'chunking' method
  43961.         MDxFinalize( &mdDataSum );
  43962.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43963.     
  43964.     MDxInit( &mdDataSum );
  43965.     MD4Translate( lpData, len, &mdDataSum );    
  43966.     printf("MD4: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  43967.  
  43968.     return;
  43969. }
  43970.  
  43971.  
  43972. -------------- Include
  43973.  
  43974. #ifndef __windows_h__
  43975.         typedef unsigned long DWORD;
  43976.         #define STDCALL _stdcall
  43977. #endif
  43978.  
  43979. typedef struct 
  43980. {
  43981.     DWORD dwSum[4];
  43982. }MDxSum;
  43983.  
  43984. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  43985. void STDCALL MDxInit( MDxSum * );
  43986. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  43987. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  43988. const char * STDCALL MDxGetVersion();
  43989. void STDCALL MDxFinalize( MDxSum * );
  43990.  
  43991.  
  43992.  
  43993. #include "mdx.h"
  43994. #include <stdlib.h>
  43995. #include <stdio.h>
  43996. #include <string.h>
  43997.  
  43998. // READLEN % 64 must = 0
  43999. #define READLEN    1048576L // 2^20, 1MB
  44000.  
  44001. void DigestFile( char * );
  44002. void DigestString();
  44003.  
  44004. void main(int argc, char *argv[])
  44005. {
  44006.     printf("%s
  44007. {
  44008.     
  44009.     //For our demo purposes, no strings bigger than 1024 :)
  44010.     unsigned char lpData[1024] = "";
  44011.     long len = 0;
  44012.     MDxSum mdDataSum;
  44013.  
  44014.     printf(     }
  44015.   
  44016.  
  44017.  
  44018. ---------ng DWORD;
  44019.         #define STDCALL _stdcall larSTTTTTTTTTTTTTTTTlong flen, mlen;
  44020.     MDxSum mdDataSum;
  44021.     MDxSum md4DataSum;
  44022.  
  44023.     // the 64 is for padding purposes
  44024.     lpData = malloc( READLEN + 64 );
  44025.     
  44026.     printf( "MD4/5 run 
  44027.     // th > READLEN )
  44028.  );
  44029.  
  44030. void main(int argc, char *argv[])
  44031. {
  44032.     printf("%s
  44033. {
  44034.     
  44035.     //For our demo purposes, no strings bigger than 1024 :)
  44036.     unsigned char lpData[1024] = "";
  44037.     long len = 0;
  44038.     MDxSum mdDataSum;
  44039.  
  44040.     printf("Enter the string to digest: ");
  44041.   (lpData);
  44042.     = strlen(lpData);
  44043.     = strlen(lpData);
  44044.     = strlen(lpData);
  44045.     = strlen(lpData);
  44046.     = strlen(lpData);
  44047.     = strlen(lpData);
  44048.     = strlen(lpData);
  44049.     = strlen(lpData);
  44050.     = strlen(lpData);Data) &mdDataSum );
  44051.     MDxInit(        if( fread( lpData, 1, READLEN, file ) method
  44052.     MDxTTTTTT{
  44053.             printf("READ ERROR!\n");
  44054.             return;
  44055.         }
  44056.         MD5Translate( lpData, READLEN, &mdDataSum );
  44057.         MD4Translate( lpData, READLEN, &md4DataSum );
  44058.         flen -= READLEN;
  44059.         printf(".");
  44060.     }
  44061.  
  44062.     if (fread( lpDaigned char lpDaE.-----ng DWORD;
  44063.         #define STDCALL _stdcall
  44064. #eROR!\n");
  44065.             return;
  44066.         }
  44067.   
  44068.  
  44069.  
  44070. ---------ng DWORD;
  44071.         #define STDCALL _stdcall larSTDCALL _stdcall
  44072. #eROR!\n");
  44073.             return;
  44074.         }
  44075.   
  44076.  
  44077.  
  44078. ---------ng DWORD;
  44079.        g szFName, "rb" );
  44080.     if( file ==     // remember that for each chunk it has to run 
  44081.     // through the main translation loop 16384 times!
  44082.         
  44083.     printf("Processing %ld byte file: .", flen );
  44084.     
  44085.     while( flen > READLEN )
  44086.     {
  44087.         if( fread( lpData, 1, READLEN, file ) != flen = mlen = ftell( file );
  44088.     fseek( file, 0, SEEK_SET );
  44089.     
  44090.     // When it takes a while to process a large file,
  44091.     // remember that for each chunk it has to run 
  44092.     // through the main translation loop 16384 times!
  44093.         
  44094.     printf("Processing %ld byte file: .", flen );
  44095.     
  44096.     while( flen > READLEN )
  44097.     {
  44098.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44099.         {
  44100.             printf("READ ERROR!\n");
  44101.             return;
  44102.         }
  44103.         MD5Translate( lpData, READLEN, &mdDataSum );
  44104.         MD4Translate( lpData, READLEN, &md4DataSum );
  44105.         flen -= READLEN;
  44106.         printf(".");
  44107.     }
  44108.  
  44109.     if (fread( lpData, 1, flen, file ) != flen)
  44110.     {
  44111.         printf("READ ERROR!\n");
  44112.         return;
  44113.     }
  44114.     // This is why I added the new argument to MDxPad
  44115.     // So we can pass the length of the data AND the
  44116.     // Total length of the message
  44117.     // Also it now returns the # of padding bytes added,
  44118.     // this is for files that are an exact multiple of the chunk
  44119.     // length. (Otherwise the padding isn't Translated)
  44120.     flen += MDxPad( lpData, flen, mlen );
  44121.     MD5Translate( lpData, flen, &mdDataSum );    
  44122.     MD4Translate( lpData, flen, &md4DataSum );
  44123.  
  44124.     // New step necessary beca
  44125.     
  44126.     MD5Translate( lpData, len, &mdDataSum );
  44127.         // New step necessary because of the 'chunking' method
  44128.         MDxFinalize( &mdDataSum );
  44129.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataS    printf("READ ERROR!\n"}    priurn;
  44130.         }
  44131.   
  44132.  
  44133.  
  44134. ---------ng DWORD;
  44135.         #define STDCALL _stdcall larSTDCALL _stdcall
  44136. #eROR!\n");
  44137.             return;
  44138.         }
  44139.   
  44140.  
  44141.  
  44142. ---------ng DWORD;
  44143.        g szFName, "rb" );
  44144.     if( file ==     // remember that for each chunk it hasa
  44145.  
  44146.     printf("Enter the string to digest: ");
  44147.     scanf("%s", &lpData );
  44148.     len = strlen(lpData);
  44149.     
  44150.     // Have to do this before the Padding...well...it's best anyway;)
  44151.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  44152.     
  44153.     // For the stDxSum * );
  44154. const char * STDCALL MDxGetVersion();
  44155. void STDCALL MDxFinalize( MDxSum * );
  44156.  
  44157.  
  44158.  
  44159. #include "mdx.h"
  44160. #include <stdlib.h>
  44161. #include <stdio.h>
  44162. #include <string.h>
  44163.  
  44164. // READLEN % 64 must = 0
  44165. #define READLEN    1048576L // 2^20, 1MB
  44166.  
  44167. void Diges  while( flen > READLEN )
  44168.     {
  44169.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44170.         {
  44171.             printf("READ ERROR!\n");
  44172.             return;
  44173.         }
  44174.         MD5Translate( lpData, READLEN, &mdDataSum );
  44175.         MD4Translate( lpData, a\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataSum.dwSum[3]);
  44176.  
  44177.     return;
  44178. }
  44179.  
  44180.  
  44181. -------------- Include
  44182.  
  44183. #ifndef __windows_h__
  44184.         typedef unsigned long DWORD;
  44185.         #define STDCALL _stdcall
  44186. #endif
  44187.  
  44188. typedef struct 
  44189. {
  44190.     DWORD dwSum[4];
  44191. }MDxSum;
  44192.  
  44193. DWORD STDCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  44194. void STDCALL MDxInit( MDxSum * );
  44195. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  44196. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  44197. const char * STDCALL MDxGetVersion();
  44198. void STDCALL MDxFinalize( MDxSum * );
  44199.  
  44200.  
  44201.  
  44202. #include "mdx.h"
  44203. #include <stdlib.h>
  44204. #include <stdio.h>
  44205. #include <string.h>
  44206.  
  44207. // READLEN % 64 must = 0
  44208. #define READLEN    1048576L // 2^20, 1MB
  44209.  
  44210. void DigestFile( char * );
  44211. void DigestString();
  44212.  
  44213. void main(int argc, char *argv[])
  44214. {
  44215.     printf("%s
  44216. {
  44217.     
  44218.     //For our demo purposes, no strings bigger than 1024 :)
  44219.     unsigned char lpData[1024] = "";
  44220.     long len = 0;
  44221.     MDxSum mdDataSum;
  44222.  
  44223.     printf(     }
  44224.   
  44225.  
  44226.  
  44227. ---------ng DWORD;
  44228.         #define STDCALL _stdcall larSTTTTTTTTTTTTTTTTlong flen, mlen;
  44229.     MDxSum mdDataSum;
  44230.     MDxSum md4DataSum;
  44231.  
  44232.     // the 64 is for padding purposes
  44233.     lpData = malloc( READLEN + 64 );
  44234.     
  44235.     printf( "MD4/5 run 
  44236.     // th > READLEN )
  44237.  );
  44238.  
  44239. void main(int argc, char *argv[])
  44240. {
  44241.     printf("%s
  44242. {
  44243.     
  44244.     //For our demo purposes, no strings bigger than 1024 :)
  44245.     unsigned char lpData[1024] = "";
  44246.     long len = 0;
  44247.     MDxSum mdDataSum;
  44248.  
  44249.     printf("Enterlen = ftell( file );
  44250.     fseek( file, 0, SEEK_SET );
  44251.     
  44252.     // When it takes a while to process a large file,
  44253.     // remember that for each chunk it has to run 
  44254.     // through the main translation loop 16384 times!
  44255.         
  44256.     printf("Processing %l * );
  44257. void DigestString();
  44258.  
  44259. void main(int argc, char *argv[])
  44260. {
  44261.     printf("%s
  44262. {
  44263.     
  44264.     //For our demo purposes, no strings bigger than 1024 :)
  44265.     unsigned char lpData[1024] = "";
  44266.     long len = 0;
  44267.     MDxSum mdDataSum;
  44268.  
  44269.     printf(     }
  44270.   bigger than 1024 :)
  44271.     unsigned char lpData[1024] = "";
  44272.     long len = 0;
  44273.     MDxSum mdDataSum;
  44274.  
  44275.     printf(     }
  44276.   bigger than 1024 :)
  44277.     unsigned char lpData[1024] = "";
  44278.     long len = 0;
  44279.     MDxSum mdDataSum;
  44280.  
  44281.     printf(     }
  44282.   bigger tember that for each chunk it has to run 
  44283.     // through the main translation loop 16384 times!
  44284.         
  44285.     printf("Processing %ld byte file: .", flen );
  44286.     
  44287.     while( flen > READLEN )
  44288.     {
  44289.         if( fread( lpData, 1, READLEN, file ) != READLEN)    while( flen > READLEN )
  44290.     {
  44291.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44292.         {
  44293.             printf("READ ERROR!\n");
  44294.             return;
  44295.         }
  44296.         MD5Translate( lpData, READLEN, &mdDataSum );
  44297.         MD4Translate( lpData ERROR!\n");
  44298.             return;
  44299.         }
  44300.         MD5Translate( lpData, READLEN, &mdDataSum );
  44301.         MD4Translate( lpData ERROR!\n");
  44302.             return;
  44303.         }
  44304.         MD5Translate( lpData, READLEN, &mdDataSum );
  44305.         MD4Translate( lpData ER!\n");
  44306.             return;
  44307.         }
  44308.         MD5Translate( lpData, READLEN, &mdDataSum );
  44309.         MD4Translate( lpData ER!\n");
  44310.             return;
  44311.         }
  44312.         MD5Translate( lpData, READLEN, &mdDataSum );
  44313.         MD4Translate( lpData ER!\n");m(".");
  44314.     }
  44315.  
  44316.     if (fread( lpData, 1, flen, file ) != flen)
  44317.     {
  44318.         printf("READ ERROR!\n");
  44319.         return;
  44320.     }
  44321.     // This is why I added the new argument to MDxPad
  44322.     // So we can pass the length of the data AND the
  44323.     // Total length of the message
  44324.     // Also it now returns the # of padding bytes added,
  44325.     // this is for files that are an exact multiple of the chunk
  44326.     // length. (Otherwise the padding isn't Translated)
  44327.     flen += MDxPad( lpData, flen, mlen );
  44328.     MD5Translate( lpData, flen, &mdDataSum );    
  44329.     MD4Translate( lpData, flen, &md4DataSum );
  44330.  
  44331.     // New step necessary beca
  44332.     
  44333.     MD5Translate( lpData, len, &mdDataSum );
  44334.         // New step necessary because of the 'chunking' method
  44335.         MDxFinalize( &mdDataSum );
  44336.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataS    printf("READ ERROR!\n"}    priurn;
  44337.         }
  44338.   
  44339.  
  44340.  
  44341. ---------ng DWORD;
  44342.         #define STDCALL _stdcall larSTDCALL _stdcall
  44343. #eROR!\n");
  44344.             return;
  44345.         }
  44346.   
  44347.  
  44348.  
  44349. ---------ng DWORD;
  44350.        g szFName, "rb" );
  44351.     if( file ==     // remember that for each chunk it hasa
  44352.  
  44353.     printf("Enter the string to digest: ");
  44354.     scanf("%s", &lpData );
  44355.     len = strlen(lpData);
  44356.     
  44357.     // Have to do this before the Padding...well...it's best anyway;)
  44358.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  44359.     
  44360.     // For the stDxSum * );
  44361. const char * STDCALL MDxGetVersion();
  44362. void STDCALL MDxFinalize( MDxSum * );
  44363.  
  44364.  
  44365.  
  44366. #include "mdADLEN )
  44367.     {
  44368.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44369.         {
  44370.             printf("READ ERROR!\n");
  44371.             return;
  44372.         }
  44373.         MD5Translate( lpData, READLEN, &mdDataSum );
  44374.         MD4Translate( lpData, a\n", mdDataSum.dw
  44375.   
  44376.  
  44377.  
  44378. ---------ng DWORD;
  44379.        g szFName, "rb" );
  44380.     if( file ==     // remember that for each chunk it hasa
  44381.  
  44382.     printf("Enter the string to digest: ");
  44383.     scanf("%s", &lpData );
  44384.     len = strlen(lpData);
  44385.     
  44386.     // Have to do this before theter the string to digest: ");
  44387.     scanf("%s", &lpData );
  44388.     len = strlen(lpData);
  44389.     
  44390.     // Have to do this before theter the string to digest: ");
  44391.     scanf("%s", &lpData );
  44392.     len = strlen(lpData);
  44393.     
  44394.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  44395. void STDCALL MDxInit( MDxSum * );
  44396. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  44397. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  44398. const char * STDCALL MDxGetVersion();
  44399. void STDCALL MDxFinalize( MDxSum * );
  44400.  
  44401.  
  44402.  
  44403. #include "mdx.h"
  44404. #include <stdlib.h>
  44405. #include <stdio.h>
  44406. #include <string.h>
  44407.  
  44408. // READLEN % 64 must = 0
  44409. #define READLEN    1048576L // 2^20, 1MB
  44410.  
  44411. void DigestFile( char * );
  44412. void DigestString();
  44413.  
  44414. voir lpData[1024] = "";
  44415.     long len = 0;
  44416.     MDxSum mdDataSum;
  44417.  
  44418.     printf(     }
  44419.   
  44420.  
  44421.  
  44422. ---------ng DWORD;
  44423.         #define STDCALL _stdcall larSTTTTTTTTTTTTTTTTlong flen, mlen;
  44424.     MDxSum mdDataSum;
  44425.     MDxSum md4DataSum;
  44426.  
  44427.     // the 64 is for padned char *, unsigned long, unsigned long );
  44428. void STDCALL MDxInit( MDxSum * );
  44429. void STDCALL MD5Translate( unsigned char *, long, or padding purposes
  44430.     lpData = malloc( READLEN + 64 );
  44431.     
  44432.     printf( "MD4/5 run 
  44433.     // th > READLEN )
  44434.  );
  44435.  
  44436. void main(int argc, char *argv[])
  44437. {
  44438.     printf("%s
  44439. {
  44440.     
  44441.     //For our demo purposes, no strings bigger than 1024 :)
  44442.     unsigned char lpData[1024] = "";
  44443.     long len = 0;
  44444.     MDxSum mdDataSum;
  44445.  
  44446.     printf("Enterlen = ftell( file );
  44447.     fseek( file, 0, SEEK_SET );
  44448.     
  44449.     // When it takes a while to process a large file,
  44450.     // remember that for each chunk it has to run 
  44451.     // throu READLEN)
  44452.         {
  44453.             printf("READ ERROR!\n");
  44454.             return;
  44455.         }
  44456.         MD5Translate( lpData, READLEN, &mdDataSum );
  44457.         MD4Translate( lpData ERROR!\n");
  44458.             return;
  44459.         }
  44460.         MD5Translate( lpData, READLEN,the pE7Data, READLEN, &mdDataSum );
  44461.         MD4Translate( lpData ER!\n");m(".");
  44462.     }
  44463.  
  44464.     if (fread( lpData, 1, flen, file ) != flen)
  44465.     {
  44466.         printf("READ ERROR!\n");
  44467.         return;
  44468.     }
  44469.     // This is why I added the new argument to MDxPad
  44470.     // So we can p( lpData, 1, fl   return;
  44471.     }
  44472.     // This is why I added the new argument to MDxPad
  44473.     // So we can p( lpData, 1, fl   return;
  44474.     }
  44475.     // This is why I added the new argument to MDxPad
  44476.     // So we can p( lpData, 1, fl   return;
  44477.     }
  44478.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44479.     // So we can p( lpData, 1, fl   return;
  44480.     }
  44481.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44482.     // So we can p( lpData, 1, fl   return;
  44483.     }
  44484.     // This is why I addeta EhiThis is why I a;
  44485.         return;
  44486.     }
  44487.     // This is why I added the new argument to MDxPad
  44488.     // So we can pass the length of the data AND the
  44489.     // Total length of the message
  44490.     // Also it now returns the # of padding bytes added,
  44491.     // this is for files tha
  44492.     // So we can p( lpData, 1, fl   return;
  44493.     }
  44494.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44495.     // So we can p( lpData, 1, fl   return;
  44496.     }
  44497.     // This is why I addeta EhiThis is why I a;
  44498.         return;
  44499.     }
  44500.    _ADLEN)    while( flen > READLEN )
  44501.     {
  44502.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44503.         {
  44504.             printf("READ ERROR!\n");
  44505.             return;
  44506.         }
  44507.         MD5Translate( lpData, READLEN, &mdDataSum );
  44508.         MD4Translate(;
  44509.             return;
  44510.         }
  44511.         MD5Translate( lpData, READLEN, &mdDataSum );
  44512.         MD4Translate( lpData ERROR!\n");
  44513.             return;
  44514.         }
  44515.         MD5Translate( lpData, READLEN, &mdDataSum );
  44516.         MD4Translate( lpData ER!\n");
  44517.             return;
  44518.         }
  44519.         MD5Translate( lpData, READLEN, &mdDataSum );
  44520.         MD4Translate( lpData ER!\n");
  44521.             return;
  44522.         }
  44523.         MD5Translate( lpData, READLEN, &mdDataSum );
  44524.         MD4Translate( lpData ER!\n");m(".");
  44525.     }
  44526.  
  44527.     if (fread( lpData, 1, flen, file ) != flen)
  44528.     {
  44529.         printf("READ ERROR!\n");
  44530.         return;
  44531.     }
  44532.     // This is why I added the new argument to MDxPad
  44533.     // So we can pass the length of the data AND the
  44534.     // Total length of the message
  44535.     // Also it now returns the # of padding bytes added,
  44536.     // this is for files that are an exact multiple of the chunk
  44537.     // length. (Otherwise the padding isn't Translated)
  44538.     flen += MDxPad( lpData, flen, mlen );
  44539.     MD5Translate( lpData, flen, &mdDataSum );    
  44540.     MD4Translate( lpData, flen, &md4DataSum );
  44541.  
  44542.     // New step necessary beca
  44543.     
  44544.     MD5Translate( lpData, len, &mdDataSum );
  44545.         // New step necessary because of the 'chunking' method
  44546.         MDxFinalize( &mdDataSum );
  44547.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0], mdDataSum.dwSum[1], mdDataSum.dwSum[2], mdDataS    printf("READ ERROR!\n"}    priurn;
  44548.         }
  44549.   
  44550.  
  44551.  
  44552. ---------ng DWORD;
  44553.         #define STDCALL _stdcall larSTDCALL _stdcall
  44554. #eROR!\n");
  44555.             return;
  44556.         }
  44557.   
  44558.  
  44559.  
  44560. ---------ng DWORD;
  44561.        g szFName, "rb" );
  44562.     if( file ==     // remember that for each chunk it hasa
  44563.  
  44564.     printf("Enter the string to digest: ");
  44565.     scanf("%s", &lpData );
  44566.     len = strlen(lpData);
  44567.     
  44568.     // Have to do this before the Padding...well...it's best anyway;)
  44569.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  44570.     
  44571.     // For the stDxSum * );
  44572. const char * STDCALL MDxGetVersion();
  44573. void STDCALL MDxFinalize( MDxSum * );
  44574.  
  44575.  
  44576.  
  44577. #include "mdADLEN )
  44578.     {
  44579.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44580.         {
  44581.             printf("READ ERROR!\n");
  44582.             return;
  44583.         }
  44584.         MD5Translate( lpData, READLEN, &mdDataSum );
  44585.         MD4Translate( lpData, a\n", mdDataSum.dw
  44586.   
  44587.  
  44588.  
  44589. ---------ng DWORD;
  44590.        g szFName, "rb" );
  44591.     if( file ==     // remember that for each chunk it hasa
  44592.  
  44593.     printf("Enter the string to digest: ");
  44594.     scanf("%s", &lpData );
  44595.     len = strlen(lpData);
  44596.     
  44597.     // Have to do this before theter the string to digest: ");
  44598.     scanf("%s", &lpData );
  44599.     len = strlen(lpData);
  44600.     
  44601.     // Have to do this before theter the string to digest: ");
  44602.     scanf("%s", &lpData );
  44603.     len = strlen(lpData);
  44604.     
  44605.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  44606. void STDCALL MDxInit( MDxSum * );
  44607. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  44608. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  44609. const char * STDCALL MDxGetVersion();
  44610. void STDCALL MDxFinalize( MDxSum * );
  44611.  
  44612.  
  44613.  
  44614. #include "mdx.h"
  44615. #include <stdlib.h>
  44616. #include <stdio.h>
  44617. #include <string.h>
  44618.  
  44619. // READLEN % 64 must = 0
  44620. #define READLEN    1048576L // 2^20, 1MB
  44621.  
  44622. void DigestFile( char * );
  44623. void DigestString();
  44624.  
  44625. voir lpData[o we can p( lpData, 1, fl   return;
  44626.     }
  44627.     // This is why I added the new argument to MDxPad
  44628.     // So we can p( lpData, 1, fl   return;
  44629.     }
  44630.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44631.     // So we can p( lpData, 1,  // So we can p( lpData, 1, fl   return;
  44632.     }
  44633.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44634.     // So we can p( lpData, 1, fl   return;
  44635.     }
  44636.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44637.     /nslate( lpData, READLEN, &mdDataSum );
  44638.         MD4Translate( lpData ER!\n");m(".");
  44639.     }
  44640.  
  44641.     if (fread( lpData, 1, flen, file ) != flen)
  44642.     {
  44643.         printf("READ ERROR!\n");
  44644.         return;
  44645.     }
  44646.     // This is why I added the new argument to M       MD5Translate( lpData, READLEN,the pE7Data, READLEN, &mdDataSum );
  44647.         MD4Translate( lpData ER!\n");m(".");
  44648.     }
  44649.  
  44650.     if (fread( lpData, 1, flen, file ) != flen)
  44651.     {
  44652.         printf("READ ERROR!\n");
  44653.         return;
  44654.     }
  44655.     // This isV can p( lpData, 1, fl   return;
  44656.     }
  44657.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44658.     // So we can p( lpData, 1, fl   return;
  44659.     }
  44660.     // This is why I addeta EhiThis is why I a;
  44661.         return;
  44662.     }
  44663.     // This is why I added the new argument to MDxPad
  44664.     // So we can pass the length of the data AND the
  44665.     // Total length of the message
  44666.     // Also it now returns the # of padding bytes added,
  44667.     // this is for files tha
  44668.     // So we can p( lpData, 1, fl   return;
  44669.     }
  44670.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44671.     // So we can p( lpData, 1, fl   return;
  44672.     }
  44673.     // This is why I addeta EhiThis is why I a;
  44674.         return;
  44675.     }
  44676.    _ADLEN)    while( flen > READLEN )
  44677.     {
  44678.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44679.         {
  44680.             printf("READ ERROR!\n");
  44681.             return;
  44682.         }
  44683.         MD5Translate( lpData, READLEN, &mdDataSum );
  44684.         MD4Translate(;
  44685.             return;
  44686.         }
  44687.         MD5Translate( lpData, READLEN, &mdDataSum );
  44688.         MD4Translate( lpData ERROR!\n");
  44689.             return;
  44690.         }
  44691.         MD5Translate( lpData, READLEN, &mdDataSum );
  44692.         MD4Translate( lpData ER!\n");
  44693.             return;
  44694.         }
  44695.         MD5Translate( lpData, READLEN, &mdDataSum );
  44696.         MD4Translate( lpData ER!\n");
  44697.             return;
  44698.         }
  44699.         MD5Translate( lpData, READLEN, &mdDataSum );
  44700.         MD4Translate( lpData ER!\n");m(".");
  44701.     }
  44702.  
  44703.     if (fread( lpData, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  44704.         {
  44705.             printf("READ ERROR!\n");
  44706.             return;
  44707.         }
  44708.         MD5Translate( lpData, READLEN, &mdDataSum );
  44709.         MD4Translate(;
  44710.             return;
  44711.         }
  44712.         MD5Translate( flen, file ) !=kn = strlen(lpData);
  44713.     
  44714.     // Have to do this before theter the string to digest: ");
  44715.     scanf("%s", &lpData );
  44716.     len = strlen(lpData);
  44717.     
  44718.     // Have to do this before theter the string to digest: ");
  44719.     scanf("%s", &lpData );
  44720.     len = strlrlen(lpData);ber that for eave to do this ba
  44721.  
  44722.     printf("Enter the string to digest: ");
  44723.     scanf("%s", &lpData );
  44724.     len = strlen(lpData);
  44725.     
  44726.     // Have to do this before theter the string to digest: ");
  44727.     scanf("%s", &lpData );
  44728.     len = strlen(lpData);
  44729.     
  44730.     // Have to do this before theter the string to digest: ");
  44731.     ta, 1, fl   ret, &md4DataSum );
  44732.  
  44733.     // New step necessary beca
  44734.     
  44735.     MD5Translate( lpData, len, &mdDataSum );
  44736.         // New step necessary because of the 'chunking' method
  44737.         MDxFinalize( &mdDataSum );
  44738.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  44739. const char * STDCALL MDxGetVersion();
  44740. void STDCALL MDxFinalize( MDxSum * );
  44741.  
  44742.  
  44743.  
  44744. #include "mdx.h"
  44745. #include <stdlib.h>
  44746. #include <stdio.h>
  44747. #include <string.h>
  44748.  
  44749. // READLEN % 64 must = 0
  44750. #define READLEN    1048576L // 2^20, 1MB
  44751.  
  44752. voiiiiiiiiiiiiiiii    
  44753.     // Have to do this before the Padding...well...it's best anyway;)
  44754.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  44755.     
  44756.     // For the stDxSum * );
  44757. const char * STDCALL MDxGetVersion();
  44758. void STDCALL MDxFinalize( MDxSum * );
  44759.  
  44760.  
  44761.  
  44762. #includ  }
  44763.   bigger tember that for each chunk it has to run 
  44764.     // through the main translation loop 16384 times!
  44765.         
  44766.     printf("Processing %ld byte file: .", flen );
  44767.     
  44768.     while( flen > READLEN )
  44769.     {
  44770.         if( fread( lpData, 1, READLEN, fil   
  44771.     // For the stDxSum * );
  44772. const char * STDCALL MDxGetVersion();
  44773. void STDCALL MDxFinalize( MDxSum * );
  44774.  
  44775.  
  44776.  
  44777. #includ  }
  44778.   bigger tember that for each chunk it has to run 
  44779.     // through the main translation loop 16384 times!
  44780.         
  44781.     printfude "mdADLEN )
  44782.     {
  44783.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44784.         {
  44785.             printf("READ ERROR!\n");
  44786.             return;
  44787.         }
  44788.         MD5Translate( lpData, READLEN, &mdDataSum );
  44789.         MD4Translate( lpData, a\n", mdDataSum.dw
  44790.   
  44791.  
  44792.  
  44793. ---------ng DWORD;
  44794.        g szFName, "rb" );
  44795.     if( file ==     // remember that for each chunk it hasa
  44796.  
  44797.     printf("Enter the string to digest: ");
  44798.     scanf("%s", &lpData );
  44799.     len = strlen(lpData);
  44800.     
  44801.     // Have to do this before theter the string to digest: ");
  44802.     scanf("%s", &lpData );
  44803.     len = strlen(lpData);
  44804.     
  44805.     // Have to do this before theter the string to digest: ");
  44806.     scanf("%s", &lpData );
  44807.     len = strlen(lpData);
  44808.     
  44809.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  44810. void STDCALL MDxInit( MDxSum * );
  44811. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  44812. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  44813. const char * STDCALL MDxGurn;
  44814.     }
  44815.     // This isV can p( lpData, 1, fl   return;
  44816.     }
  44817.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44818.     // So we can p( lpData, 1, fl   return;
  44819.     }
  44820.     // This is why I addeta EhiThis is why I a;
  44821.         retur( lpDaoir lpData[o we can p( lpData, 1, fl   return;
  44822.     }
  44823.     // This is why I added the new argument to MDxPad
  44824.     // So we can p( lpData, 1, fl   return;
  44825.     }
  44826.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44827.     // So we can p( lpData, 1,  // So we can p( lpData, 1, fl   return;
  44828.     }
  44829.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44830.     // So we can p( lpData, 1, fl   return;
  44831.     }
  44832.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44833.     /nslate( lpData, READLEN, &mdDataSum );
  44834.         MD4Translate( lpData ER!\n");m(".");
  44835.     }
  44836.  
  44837.     if (fread( lpData, 1, flen, file ) != flen)
  44838.     {
  44839.         printf("READ ERROR!\n");
  44840.         return;
  44841.     }
  44842.     // This is why I added the new argument to M       MD5Translate( lpData, READLEN,the pE7Data, READLEN, &mdDataSum );
  44843.         MD4Translate( lpData ER!\n");m(".");
  44844.     }
  44845.  
  44846.     if (fread( lpData, 1, flen, file ) != flen)
  44847.     {
  44848.         printf("READ ERROR!\n");
  44849.         return;
  44850.     }
  44851.     // This isV can p( lpData, 1, fl   return;
  44852.     }
  44853.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  44854.     // So we can p( lpData, 1, fl   return;
  44855.     }
  44856.     // This is why I addeta EhiThis is why I a;
  44857.         return;
  44858.     }
  44859.     // This i 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  44860.         {
  44861.             printf("READ ERROR!\n");
  44862.             return;
  44863.         }
  44864.         MD5Translate( lpData, READLEN, &mdDataSum );
  44865.         MD4Translate(;
  44866.             return;
  44867.         }
  44868.          // spData, _;
  44869.         MD4Translate( lpData ER!\n");
  44870.             return;
  44871.         }
  44872.         MD5Translate( lpData, READLEN, &mdDataSum );
  44873.         MD4Translate( lpData ER!\n");
  44874.             return;
  44875.         }
  44876.         MD5Translate( lpData, READLEN, &mdDataSum );
  44877.         MD4Translate( lpData ER!\n");m(".");
  44878.     }
  44879.  
  44880.     if (fread( lpData, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  44881.         {
  44882.             printf("READ ERROR!\n");
  44883.             return;
  44884.         }
  44885.         MD5Translate( lpData, READLEN, &mdDataSum );
  44886.         MD4Translate(;
  44887.             return;
  44888.         }
  44889.         MD5Translate( flen, file ) !=kn = strlen(lpData);
  44890.     
  44891.     // Have to do this before theter the string to digest: ");
  44892.     scanf("%s", &lpData );
  44893.     len = strlen(lpData);
  44894.     
  44895.     // Have to do this before theter the string to digest: ");
  44896.     scanf("%s", &lpData );
  44897.     len = strlrlen(lpData);ber that for eave to do this ba
  44898.  
  44899.     printf("Enter the string to digest: ");
  44900.     scanf("%s", &lpData );
  44901.     len = strlen(lpData);
  44902.     
  44903.     // Have to do this before theter the string to digest: ");
  44904.     scanf("%s", &lpData );
  44905.     len = strlen(lpData);
  44906.     
  44907.     // Have to do this before theter the string to digest: ");
  44908.     ta, 1, fl   ret, &md4DataSum );
  44909.  
  44910.     // New step necessary beca
  44911.     
  44912.     MD5Translate( lpData, len, &mdDataSum );
  44913.         // New step necessary because of the 'chunking' method
  44914.         MDxFinalize( &mdDataSum );
  44915.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  44916. const char * STDCALL MDxGetVersion();
  44917. void STDCALL MDxFinalize( MDxSum * );
  44918.  
  44919.  
  44920.  
  44921. #include "mdx.h"
  44922. #include <stdlib.h>
  44923. #include <stdio.h>
  44924. #include <string.h>
  44925.  
  44926. // READLEN % 64 must = 0
  44927. #define READLEN    1048576L // 2^20, 1MB
  44928.  
  44929. voiiiiiiiiiiiiiiii    
  44930.     // Have to do this before the Padding...well...it's best anyway;)
  44931.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  44932.     
  44933.     // For the stDxSum * );
  44934. const char * STDCALL MDxGetVersion();
  44935. void STDCALL MDxFinalize( MDxSum * );
  44936.  
  44937.  
  44938.  
  44939. #includ  }
  44940.   bigger tember that for each chunk it has to run 
  44941.     // through the main translation loop 16384 times!
  44942.         
  44943.     printf("Processing %ld byte file: .", flen );
  44944.     
  44945.     while( flen > READLEN )
  44946.     {
  44947.         if( fread( lpData, 1, READLEN, fil   
  44948.  
  44949.             printf("READ ERROR!\n");
  44950.             return;
  44951.         }
  44952.         MD5Translate( lpData, READLEN, &mdDataSum );
  44953.         MD4Translate( lpData, a\n", mdDataSum.dw
  44954.   
  44955.  
  44956.  
  44957. ---------ng DWORD;
  44958.        g szFName, "rb" );
  44959.     if( file ==     // reme--ng DWORD;
  44960.        g szFName, "rb" );
  44961.     if( file ==     // reme--ng DWORD;
  44962.        g szFName, "rb" );
  44963.     if( file ==     // reme--ng DWORD;
  44964.        g szFName, "rb" );
  44965.     if( file ==     // reme--ng DWORD;
  44966.        g szFName, "rb" );
  44967.     if( file ==  k szFNamg szFName, "rb" );
  44968.     if( file ==     // reme--ng DWORD;
  44969.        g szFName, "rb" );
  44970.     if( file ==  k szFNamg szFName, "rb" );
  44971.     if( file ==     // reme--ng DWORD;
  44972.        g szFName, "rb" );
  44973.     if( file ==  k szFNamg szFName, "rb" );
  44974.     if( file =k     //
  44975.     lud  }
  44976.   bigger tember that for each chunk it has to run 
  44977.     // through the main translation loop 16384 times!
  44978.         
  44979.     printfude "mdADLEN )
  44980.     {
  44981.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  44982.         {
  44983.             printf("READ ERROR!\n");
  44984.             return;
  44985.         }
  44986.         MD5Translate( lpData, READLEN, &mdDataSum );
  44987.         MD4Translate( lpData, a\n", mdDataSum.dw
  44988.   
  44989.  
  44990.  
  44991. ---------ng DWORD;
  44992.        g szFName, "rb" );
  44993.     if( file ==     // remember that for each chunk it hasa
  44994.  
  44995.     printf("Enter the string to digest: ");
  44996.     scanf("%s", &lpData );
  44997.     len = strlen(lpData);
  44998.     
  44999.     // Have to do this before theter the string to digest: ");
  45000.     scanf("%s", &lpData );
  45001.     len = strlen(lpData);
  45002.     
  45003.     // Have to do this before theter the string to digest: ");
  45004.     scanf("%s", &lpData );
  45005.     len = strlen(lpData);
  45006.     
  45007.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  45008. void STDCALL MDxInit( MDxSum * );
  45009. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  45010. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  45011. const char * STDCALL MDxGurn;
  45012.     }
  45013.     // This isV can p( lpData, 1, fl   return;
  45014.     }
  45015.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45016.     {
  45017.         printf("READ ERROR!\n");
  45018.         return;
  45019.     }
  45020.     // This is why I added the new argument to M       MD5Translate( lpData, READLEN,the pE7Data, READLEN, &mdDataSum );
  45021.         MD4Translate( lpDsxGurn;
  45022.     }
  45023.     // This isV can p( lpData, 1, fl   return;
  45024.     }
  45025.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45026.     {
  45027.         printf("READ ERROR!\n");
  45028.         return;
  45029.     }
  45030.     // This is why I ad    scanf("%s", why 
  45031.     len = strlrlen(lpData);b, 1, flen, fileREADLEN, &mdDataSum );
  45032.         MD4Translate( lpData ER!\n");m(".");
  45033.     }
  45034.  
  45035.     if (fread( lpData, 1, flen, file ) != flen)
  45036.     {
  45037.         printf("READ ERROR!\n");
  45038.         return;
  45039.     }
  45040.     // This is why I added the new argument to M       MD5Translve to do this before theter the string to dig    {
  45041.         y I added the new argument to M       MD5Translve to do this before theter the string to dig    {
  45042.         y I added the new argument to M       MD5Translve to do this before theter the string to dig    {
  45043.         y I added the new argument to M       MD5Tra  scto M       MD5Translve to do this before theter the string to dig    {
  45044.         y I added the new argument to M       MD5Tra  scto M       MD5Translve to do this before theter the string to dig    {
  45045.         y I added the new argument to M       MD5Tra  sctone READLEN    1048576L // 2^20, 1MB
  45046.  
  45047. voiiiiiiiiiiiiiiii    
  45048.     // Have to do this beforun 
  45049.     // thk.well...it's best anyway;)
  45050.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  45051.     
  45052.     // For the stDxSum * );
  45053. const char * STDCALL MDxGetVersion();
  45054. void STDCALL MDxFinalize( MDxSum * );
  45055.  
  45056.  
  45057.  
  45058. #includ  }
  45059.   bigger tember that for each chunk it has tember that forent to M       MD5Translve to do thh"
  45060. #include <stdlib.h>
  45061. #include <stdio.h>
  45062. #include <string.h>
  45063.  
  45064. // READLEN % 64 must = 0
  45065. #define READLEN    1048576L // 2^20, 1MB
  45066.  
  45067. voiiiiiiiiiiiiiiii    
  45068.     // Have to do this before the Padding...well...it's best anyway;)
  45069.     printf( "MD4/5 Digest\"%s\":E7late( unsigned char *, long, MDxSum * );
  45070. const char * STDCALL MDxGurn;
  45071.     }
  45072.     // This isV can p( lpData, 1, fl   return;
  45073.     }
  45074.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45075.     {
  45076.         printf("can p( lpData, 1, fl   return;
  45077.     }
  45078.     // This is why I addeta Ehis is why I added the new argument to MDxPad
  45079.     // So we can p( lpData, 1,  // So we can p( lpData, 1, fl   return;
  45080.     }
  45081.     // This is why I addeta Ehis is why I added the new argumenn p( lpData, 1,  // So we can p( lpData, 1, fl   return;
  45082.     }
  45083.     // This is why I addeta Ehis is why I added the new argumenn p( lpData, 1,  // So we can p( lpData, 1, fl   return;
  45084.     }
  45085.     // This is why I addeta Ehis is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45086.         // New step necessary because of the 'chunking' method
  45087.         MDxFinalize( &mdDataSum );
  45088.     printf("MD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  45089. const chate( lpData, a\n", mdDataSum.dw
  45090.   
  45091.  
  45092.  
  45093. ----&mdDataSum );
  45094. e( unsigned char *, long, MDxSum * );
  45095. const chate( lpData, a\n", mdDataSum.dw
  45096.   
  45097.  
  45098.  
  45099. ----&mdDataSum );
  45100. e( unsigned char *, long, MDxSum * );
  45101. const chate( lpData, a\n", mdDataSum.dw
  45102.   
  45103.  
  45104.  
  45105. ----&mdDataSum );
  45106. e( unsigned char *, long, MDxSum * );
  45107. const is DxSum * );
  45108. const chate( lpData, a\n", mdDataSum.dw
  45109.   
  45110.  
  45111.  
  45112. ----&mdDataSum );
  45113. e( unsigned char *, long, MDxSum * );
  45114. const is DxSum * );
  45115. const chate( lpData, a\n", mdDataSum.dw
  45116.   
  45117.  
  45118.  
  45119. ----&mdDataSum );
  45120. e( unsigned char *, long, MDxSum * );
  45121. const is Dxnsigned long, unsigned long );
  45122. void STDCALL MDxInit( MDxSum * );
  45123. void STDCALL MD5Translaring to dig    kr *, long, MDxSum * );
  45124. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  45125. const char * STDCALL MDxGurn;
  45126.     }
  45127.     // This isV can p( lpData, 1, fl   return;
  45128.     }
  45129.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, fded the ne if (g, MDxSum * );
  45130. const chate( lpData= strlen(lpData);
  45131.     
  45132.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  45133. void STDCALL MDxInit( MDxSum * );
  45134. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  45135. void STDCALL MD4Translate( unchar *,E7um * );
  45136. const char * STDCALL MDxGurn;
  45137.     }
  45138.     // This isV can p( lpData, 1, fl   return;
  45139.     }
  45140.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45141.     {
  45142.         printf("can p( lpData, 1, fl   return;
  45143.          MD5Translate( lpData, READLEN, &mdDataSum );
  45144.         MD4Translate( lpData ER!\n");m(".");
  45145.     }
  45146.  
  45147.     if (fread( lpData, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  45148.         {
  45149.             printf("READ ERROR!\n");
  45150.             returna, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  45151.         {
  45152.             printf("READ ERROR!\n");
  45153.             returna, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  45154.         {
  45155.             printf("READ ERROR!\n");
  45156.             returna, I added the ne;
  45157.              chunk it hasa
  45158.  
  45159.     printf("Enter the string to digest: ");
  45160.     scanf("%s", &lpData );
  45161.     len = strlen(lpData);
  45162.     
  45163.     // Have to do this before theter the string to digest: ");
  45164.     scanf("%s", &lpData );
  45165.     len = strlen(lpData);
  45166.     
  45167.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45168.     len = strlen(lpData);
  45169.     
  45170.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45171.     len = strlen(lpData);
  45172.     
  45173.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45174.     len = strlen(lpData);
  45175.     
  45176.     // ERRO);
  45177.     
  45178.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45179.     len = strlen(lpData);
  45180.     
  45181.     // ERRO);
  45182.     
  45183.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45184.     len = strlen(lpData);
  45185.     
  45186.     // ERRO);iiiiiii    
  45187.     // Have to do this before the Padding...well...it's best anyway;)
  45188.     pr 
  45189.  
  45190.  
  45191. ----&mdDkest\"%s\":E7late( unsigned char *, long, MDxSum * );
  45192. const char * STDCALL MDxGurn;
  45193.     }
  45194.     // This isV can p( lpData, 1, fl   return;
  45195.     }
  45196.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45197.     {
  45198.     flen, file ) !=Data);
  45199.     
  45200.     // Hav     MD5Traude <string.h>
  45201.  
  45202. // READLEN % 64 must = 0
  45203. #define READLEN    1048576L // 2^20, 1MB
  45204.  
  45205. voiiiiiiiiiiiiiiii    
  45206.     // Have to do this before the Padding...well...it's best anyway;)
  45207.     printf( "MD4/5 Digest\"%s\":E7late( unsigned char *, long, MDxSum * );char * E7Gurn;
  45208.     }
  45209.     // This isV can p( lpData, 1, fl   return;
  45210.     }
  45211.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45212.     {
  45213.         printf("can p( lpData, 1, fl   return;
  45214.          MD5Translate( lpData, REAn translation loop 16384 times!
  45215.         
  45216.     printfude "mdADLEN )
  45217.     {
  45218.         if( fread( lpData, 1, READLEN, file ) != READLEN)
  45219.         {
  45220.             printf("READ ERROR!\n");
  45221.             return;
  45222.         }
  45223.         MD5Translate( lpData, READLEN, &mdEN)
  45224.         {
  45225.             printf("READ ERROR!\n");
  45226.             return;
  45227.         }
  45228.         MD5Translate( lpData, READLEN, &mdEN)
  45229.         {
  45230.             printf("READ ERROR!\n");
  45231.             return;
  45232.         }
  45233.         MD5Translate( lpData, READLEN, &mdEN( unsigned char lpData, READLE's best anyway;)
  45234.     printf( "MD4/5 Digests of \n\"%s\":\n", lpData );
  45235.     
  45236.     // For the stDxSum * );
  45237. const char * STDCALL MDxGetVersion();
  45238. void STDCALL MDxFinalize( MDxSum * );
  45239.  
  45240.  
  45241.  
  45242. #includ  }
  45243.   bigger tember that for each chunk it has tember tha* );
  45244. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember tha* );
  45245. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember tha* );
  45246. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannk it has tember tha* );
  45247. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannk it has tember tha* );
  45248. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45249.  
  45250. ----&mdDataSum );
  45251. e( unsigned char *, long, MDxSum * );
  45252. const is Dxnsigned long, unsigned long );
  45253. void STDCALL MDxInit( MDxSum * );
  45254. void STDCALL MD5Translaring to dig    kr *, long, MDxSum * );
  45255. void STDCALL MD4Translate( unsigned char *, long, MDxSumlong, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannk it has tember tha* );
  45256. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45257.  
  45258. ----&mdDataSum );
  45259. e( unsig_ 1, fl   return;
  45260.     }
  45261.     // This is why I addeta Ehis is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45262.         // New step necessary because of the 'chunking' method
  45263.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  45264. const chate( lpData, a\n", mdDataSum.dw
  45265.   
  45266.  
  45267.  
  45268. ----&mdDataSum );
  45269. e( unsigned char *, long, MDxSum * );
  45270. const chate( lpData, a\n", mdDataSum.dw
  45271.   
  45272.  
  45273.  
  45274. ----&mdDataSum );
  45275. e( unsigned char *, long, MDxSum * );
  45276. const chate( lpData, a\n", mdDataSum.dw
  45277.   
  45278.  
  45279.  
  45280. ----&mdDataSum );
  45281. e( unsigned char *, long, MDxSum * );
  45282. const is DxSum * );
  45283. const chate( lpData, a\n", mdDataSum.dw
  45284.   
  45285.  
  45286.  
  45287. ----&mdDataSum );
  45288. e( unsigned char *, long, MDxSum * );
  45289. const is DxSum * );
  45290. const chate( lpData, a\n", mdDataSum.dw
  45291.   
  45292.  
  45293.  
  45294. ----&mdDataSum );
  45295. e( unsigned char *, long, MDxSum * );
  45296. const is Dxnsigned long, unsigned long );
  45297. void STDCALL MDxInit( MDxSum * );
  45298. void STDCALL MD5Translaring to dig    kr *, long, MDxSum * );
  45299. void STDCALL MD4Translate( unsigned char *, long, MDxSum * );
  45300. const char * STDCALL MDxGurn;
  45301.     }
  45302.     // This isV can p( lpData, 1, fl   return;
  45303.     }
  45304.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, fded the ne if (g, MDxSum * );
  45305. const chate( lpData= strlen(lpData);
  45306.     
  45307.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  45308. void STDCALL MDxInit( MDxSum * );
  45309. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  45310. void STDCALL MD4Translate( unchar *,E7um * );
  45311. const char * STDCALL MDxGurn;
  45312.     }
  45313.     // This isV can p( lpData, 1, fl   return;
  45314.     }
  45315.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45316.     {
  45317.         printf("can p( lpData, 1, fl   return;
  45318.          MD5Translate( lpData, READLEN, &mdDataSum );
  45319.         MD4Translate( lpData ER!\n");m(".");
  45320.     }
  45321.  
  45322.     if (fread( lpData, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  45323.         {
  45324.             printf("READ ERROR!\n");
  45325.             returna, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  45326.         {
  45327.             printf("READ ERROR!\n");
  45328.             returna, 1, flen, fileead( lpData, 1, READLEN, file ) != READLEN)
  45329.         {
  45330.             printf("READ ERROR!\n");
  45331.             returna, I added the ne;
  45332.              chunk it hasa
  45333.  
  45334.     printf("Enter the string to digest: ");
  45335.     scanf("%s", &lpData );
  45336.     len = strlen(lpData);
  45337.     
  45338.     // Have to do this before theter the string to digest: ");
  45339.     scanf("%s", &lpData );
  45340.     len = strlen(lpData);
  45341.     
  45342.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45343.     len = strlen(lpData);
  45344.     
  45345.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45346.     len = strlen(lpData);
  45347.     
  45348.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45349.     len = strlen(lpData);
  45350.     
  45351.     // ERRO);
  45352.     
  45353.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45354.     len = strlen(lpData);
  45355.     
  45356.     // ERRO);
  45357.     
  45358.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45359.     len = strlen(lpData);
  45360.     
  45361.     // ERRO);iiiiiii    
  45362.     // Have to do this before the Padding...well...it's best anyway;)
  45363.     pr 
  45364.  
  45365.  
  45366. ----&mdDkest\"%s\":E7late( unsigned char *, long, MDxSum * );
  45367. const char * STDCALL MDxGurn;
  45368.     }
  45369.     // This isV can p( lpData, 1, fl   return;
  45370.     }
  45371.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45372.     {
  45373.     flen, file ) !=Data);
  45374.     
  45375.     // Hav     MD5Traude <string.h>
  45376.  
  45377. // READLEN % 64 must = 0
  45378. #define READLEN    1048576L // 2^20, 1MB
  45379.  
  45380. voiiiiiiiiiiiiiiii    
  45381.     // Have to do this before the Padding...well...it's best anyway;)
  45382.     printf( "MD4/5 Digest\"%s\":E7late( unsigned char *, long, MDxSum * );char * E7Gurn;
  45383.     }
  45384.     // This isV can p( lpData, 1, fl   return;
  45385.     }
  45386.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45387.     {
  45388.         
  45389.             return;
  45390.         }
  45391.         MD5Translate( lpData, READLEN, &mdEN)
  45392.         {
  45393.             printf("READ ERROR!\n");
  45394.             return;
  45395.         }
  45396.         MD5Translate( lpData, READLEN, &mdEN)
  45397.         {
  45398.             printf("READ ERROR!\n");
  45399.  lpData, READLEN, &mdEN)
  45400.         {
  45401.             printf("READ ERROR!\n");
  45402.  lpData, READLEN, &mdEN)
  45403.         {
  45404.             printf("READ ERROR!\n");
  45405.  lpData, READLEN, &mdEN)
  45406.         {
  45407.             printf("READ ERROR!\n");
  45408.  lpData, READLEN, &mdEN)
  45409.        ha* );
  45410. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45411.  
  45412. ----&mdDataSum );
  45413. e( unsigned char *, long, MDxSum * );
  45414. const is Dxnsigned long, unsigned long );
  45415. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  45416.  
  45417. ----&mdDataSum );
  45418. e( unsigned char *, long, MDxSum * );
  45419. const is Dxnsigned long, unsigned long );
  45420. void STDCALL MDxInit( MDxSum * );
  45421. void STDCALL MD5Translaring to dig    kr *, long, MDxSum * );
  45422. void STDCALL MD4Translate( unsigned char *, long, MDxSumlong, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannk it has tember tha* );
  45423. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45424.  
  45425. ----&mdDataSum );
  45426. e( unsig_ 1, fl   return;
  45427.     }
  45428.     // This is why I addeta Ehis is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45429.         // New step necessary because of the 'chunking' method
  45430.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  45431. const chate( lpData, a\n", mdDataSum.dw
  45432.   
  45433.  
  45434.  
  45435. ----&mdDataSum );
  45436. e( unsigned char *, long, MDxSum * );
  45437. const chate( lpData, a\n", mdDataSum.dw
  45438.   
  45439.  
  45440.  
  45441. ----&mdDataSum );
  45442. e( unsigned char *, long, MDxSum * );
  45443. const chate( lpData, a\n", mdDataSum.dw
  45444.   
  45445.  
  45446.  
  45447. ----&mdDataSum );
  45448. e( unsigned char *, long, MDxSum * );
  45449. const is DxSum * );
  45450. const chate( lpData, a\n", mdDataSum.dw
  45451.   
  45452.  
  45453.  
  45454. ----&mdDat is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45455.         // New step necessary because of the 'chunking' method
  45456.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate(n", mdDataSum.dw
  45457.   
  45458.  
  45459.  
  45460. ----&mdDataSum );
  45461. e( unsigned char *, long, MDxSum * );
  45462. const is DxSum * );
  45463. const chate( lpData, a\n", mdDataSum.dw
  45464.   
  45465.  
  45466.  
  45467. ----&mdDataSum );
  45468. e( unsigned char *, long, MDxSum * );
  45469. const is DxSum * );
  45470. const chate( lpData, a\n"long, MDxSum * );
  45471. const is DxSum * );
  45472. const chate( lpData, a\n", mdDataSum.dw
  45473.   
  45474.  
  45475.  
  45476. ----&mdDataSum );
  45477. e( unsigned char *, long, MDxSum * );
  45478. const is Dxnsigned long, unsigned long );
  45479. void STDCALL MDxInit( MDxSum * );
  45480. void STDCALL MD5Translaring to ding, MD * );
  45481. const char * STDCALL MDxGurn;
  45482.     }
  45483.     // This isV can p( lpData, 1, fl   return;
  45484.     }
  45485.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45486.     {
  45487.         printf("can p( lpData, 1, fl   return;
  45488.    
  45489. const char * * );
  45490. const char * STDCALL MDxGurn;
  45491.     }
  45492.     // This isV can p( lpData, 1, fl   return;
  45493.     }
  45494.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, fded the ne if (g, MDxSum * );
  45495. const chate( lpData= strlen(lpData);
  45496.     
  45497.     // Have to do this before theter the mCALL MDxPad ( unsigned char *, unsigned long, unsigned long );
  45498. void STDCALL MDxInit( MDxSum * );
  45499. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  45500. void STDCALL MD4Translate( unchar *,E7um * );
  45501. const char * STDCALL MDxGurn;
  45502.     }
  45503.     // This isV can p( lpData, 1, fl   return;
  45504.     }
  45505.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45506.     {
  45507.         printf("can p( lpData, 1, fl   return;
  45508.          MD5Translate(   
  45509.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45510.     len = strlen(lpData);
  45511.     
  45512.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45513.     len = strlen(lpData);
  45514.     
  45515.     // Hav     MD5Tra  sctone READLEN  // This isV can p( lpData, 1, fl   return;
  45516.     }
  45517.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45518.     {
  45519.         printf("can p( lpData, 1, fl   return;
  45520.          MD5Translate(   
  45521.     // Hav     MD5Tra  scrn;
  45522. MD5Tra  scREADLEN    1048576L // 2^ Have to do thi);
  45523.     len = strlen(lpData);
  45524.     
  45525.     // ERRO);
  45526.     
  45527.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45528.     len = strlen(lpData);
  45529.     
  45530.     // ERRO);iiiiiii    
  45531.     // Have to do this befo
  45532.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45533.     len = strlen(lpData);
  45534.     
  45535.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45536.     len = strlen(lpData);
  45537.     
  45538.     // Hav     MD5Tra  sctone READLEN    1ne READLEN    1ne READLData, 1, flen, file ) != flen)
  45539.     {
  45540.     flen, file ) !=Data);
  45541.     
  45542.     // Hav     MD5Traude <string.h>
  45543.  
  45544. // READLEN % 64 must = 0
  45545. #define READLEN    1048576L // 2^20, 1MB
  45546.  
  45547. voiiiiiiiiiiiiiiii    
  45548.     // Have to do this before the Padding...well...it's best anyway;)
  45549.     printf( "MD4/5 Digest\"%s\":E7late( unsigned char *, long, MDxSum * );char * E7Gurn;
  45550.     }
  45551.     // This isV can p( lpData, 1, fl   return;
  45552.     }
  45553.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45554.     {
  45555.         
  45556.             return;
  45557.         }
  45558.         MD5Translate( lpData, READLEN, &mdEN)
  45559.         {
  45560.             printf("READ ERROR!\n");
  45561.             return;
  45562.         }
  45563.         MD5Translate( lpData, READLEN, &mdEN)
  45564.         {
  45565.             printf("READ ERROR!\n");
  45566.  lpData, READLEN, &mdEN)
  45567.         {
  45568.             printf("READ ERROR!\n");
  45569.  lpData, READLEN, &mdEN)
  45570.         {
  45571.             printf("READ ERROR!\n");
  45572.  lpData, READLEN, &mdEN)
  45573.         {
  45574.             printf("READ ERROR!\n");
  45575.  lpData, READLEN, &mdEN)
  45576.        ha* );
  45577. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45578.  
  45579. ----&mdDataSum );
  45580. e( unsigned char *, long, MDxSum * );
  45581. const is Dxnsigned long, unsigned long );
  45582. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  45583.  
  45584. ----&mdDataSum );
  45585. e( unsigned char *, long, MDxSum * );
  45586. const is Dxnsigned long, unsigned long );
  45587. void STDCALL MDxInit( MDxSum * );
  45588. void STDCALL MD5Translaring to dig    kr *, long, MDxSum * );
  45589. void STDCALL MD4Translate( unsigned char *, long, MDxSumlong, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannk it has tember tha* );
  45590. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45591.  
  45592. ----&mdDataSum );
  45593. e( unsig_ 1, fl   return;
  45594.     }
  45595.     // This is why I addeta Ehis is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45596.         // New step necessary because of the 'chunking' method
  45597.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  45598. const chate( lpData, a\n", mdDataSum.dw
  45599.   
  45600.  
  45601.  
  45602. ----&mdDataSum );
  45603. e( unsigned char *, long, MDxSum * );
  45604. const chate( lpData, a\n", mdDataSum.dw
  45605.   
  45606.  
  45607.  
  45608. ----&mdDataSum );
  45609. e( unsigned char *, long, MDxSum * );
  45610. const chate( lpData, a\n", mdDataSum.dw
  45611.   
  45612.  
  45613.  
  45614. ----&mdDataSum );
  45615. e( unsigned char *, long, MDxSum * );
  45616. const is DxSum * );
  45617. const chate( lpData, a\n", mdDataSum.dw
  45618.   
  45619.  
  45620.  
  45621. ----&mdDat is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45622.         // New step necessary because of the 'chunking' method
  45623.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate(n", mdDataSum.dw
  45624.   
  45625.  
  45626.  
  45627. ----&mdDataSum );
  45628. e( unsigned char *, long, MDxSum * );
  45629. const is DxSum * );
  45630. const chate( lpData, a\n", mdDataSum.dw
  45631.   
  45632.  
  45633.  
  45634. ----&mdDataSum );
  45635. e( unsigned char *, long, MDxSum * );
  45636. const is DxSum * d char *, unsigned long, unsigned long );
  45637. void STDCALL MDxInit( MDxSum * );
  45638. void STDCALL MD5Translate( unsigned char *, long, MDxSum * );
  45639. void STDCALL MD4Translate( unchar *,E7um * );
  45640. const char * STDCALL MDxGurn;
  45641.     }
  45642.     // This isV can p( lpData, 1 *, long, MDxSum * );
  45643. const is DxSum * );
  45644. const chate( lpData, a\n", mdDataSum.dw
  45645.   
  45646.  
  45647.  
  45648. ----&mdDataSum );
  45649. e( unsigned char *, long, MDxSum * );
  45650. const is DxSum * );
  45651. const chate( lpData, a\n"long, MDxSum * );
  45652. const is DxSum * );
  45653. const chate( lpData, :lhate( (7   // ERRO);
  45654.     
  45655.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45656.     len = strlen(lpData);
  45657.     
  45658.     // ERRO);iiiiiii    
  45659.     // Have to do this befo
  45660.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45661.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45662.  
  45663. ----&mdDataSum );
  45664. e( unsig_ 1, fl   return;
  45665.     }
  45666.     // This is why I addeta Ehis is why I added the new argumenn in translation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  45667.     {
  45668.         
  45669.             return;
  45670.         }
  45671.         MD5Translate( lpData, READLEN, &mdEN)
  45672.         {
  45673.             printf("READ ERROR!\n");
  45674.             return;
  45675.         }
  45676.         MD5Translate( lthe ne if (frE7Gurn;
  45677.     }    {
  45678.         V can p( lpData, 1, fl   return;
  45679.     }
  45680.     // This is why I addeta Ehis is why I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45681.     {
  45682.         
  45683.             return;
  45684.         }
  45685.         MD5Translate( lpData, READLEN, &mdEN)
  45686.         {
  45687.             printf("READ ERROR!\n");
  45688.             returhas temb
  45689.  
  45690. ---- Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45691.     len = strlen(lpData);
  45692.     
  45693.     // Hav     MD5Tra  sctone READLEN  // This isV can p( lpData, 1, fl   return;
  45694.     }
  45695.     // This is why I addeta Ehis is why I added the ne if (fread( lE7EN, &mdEN)
  45696.         {
  45697.             printf("READ ERROR!\n");
  45698.  lpData, READLEN, &mdEN)
  45699.        ha* );
  45700. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45701.  
  45702. ----&mdDataSum );
  45703. e( unsigned char *, long, MDxSum * );
  45704. const is Dxnsigned long, unsigned long );
  45705. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  45706.  
  45707. ----&mdDataSum );
  45708. e( unsigned char *, long, MDr *, long, MDxS
  45709.         {
  45710.             printf("READ ERROR!\n");
  45711.  lpData, READLEN, &mdEN)
  45712.         {
  45713.             printf("READ ERROR!\n");
  45714.  lpData, READLEN, &mdEN)
  45715.         {
  45716.             printf("READ ERROR!\n");
  45717.  lpData, READLEN, &mdEN)
  45718.        ha* );
  45719. const is Dxnsignwhy I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45720.     {
  45721.         
  45722.             return;
  45723.         }
  45724.         MD5Translate( lpData, READLEN, &mdEN)
  45725.         {
  45726.             printf("READ ERROR!\n");
  45727.             return;
  45728.         }
  45729.         MD5Transl>I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45730.         // New step necessary because of the 'chunking' method
  45731.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long,hate( lpData, a>s is why I addeta Ehis is why I added the new argumenn in translation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  45732.     {
  45733.         
  45734.             return;
  45735.         }
  45736.         MD5Translate( lpData, READLEN, &mdEN)
  45737.         {
  45738.             prikE7D4Translate(n", mdDataSum.dw
  45739.   
  45740.  
  45741.  
  45742. ----&mdDataSum );
  45743. e( unsigned char *, long, MDxSum * );
  45744. const is DxSum * );
  45745. const chate( lpData, a\n", mdDataSum.dw
  45746.   
  45747.  
  45748.  
  45749. ----&mdDataSum );
  45750. e( unsigned char *, long, MDxSum * );
  45751. const is DxSum * d char *, unsiganslate(n", mssary because ovoid STDCALL MDctone READLEN    1048576L // 2^ Have to do thi);
  45752.     len = strlen(lpData);
  45753.     
  45754.     // ERRO);iiiiiii    
  45755.     // Have to do this befo
  45756.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45757.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  45758. e( D ERROR!\n");
  45759.  lpData, READLEN, &mdEN)
  45760.        ha* );
  45761. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45762.  
  45763. ----&mdDataSum );
  45764. e( unsigned char *, long, MDxSum * );
  45765. const is Dxnsigned lona\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  45766. const chate( lpData, a\n", mdDataSum.dw
  45767.   
  45768.  
  45769.  
  45770. ----&mdDataSum );
  45771. e( unsigned char *, long, MDxSum * );
  45772. const chate( lpData, a\n", mdDataSum.dw
  45773.   
  45774.  
  45775.  
  45776. ----&mdDataSum );
  45777. e( unsigne;
  45778. const is DxSum * );
  45779. const chate( lpData, a\n", mdDataSum.dw
  45780.   
  45781.  
  45782.  
  45783. ----&mdDat is why I added the new argumenn in transla, mdDataSum.dw
  45784.   
  45785.  
  45786.  
  45787. ----&mdDataSum );
  45788. e( unsigned char *, long, MDxSum * );
  45789. const is DxSum * );
  45790. const chate( lpData, a\n", mdDataSum.dw
  45791.   
  45792.  
  45793.  
  45794. ----&mdDat is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45795.         // New step necessary because of the 'chunking' method
  45796.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate(n", mdDataSum.dw
  45797.   
  45798.  
  45799.  
  45800. ----&mdDataSum );
  45801. e( unsigned char *, long, MDxSum * );
  45802. const is DxSum * )    1048576L // 2^ Have to do thi);
  45803.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45804.  
  45805. ----&mdDataSum );
  45806. e( unsig_ 1, fl   return;
  45807.     }
  45808.     // This is whs is a);
  45809. void STDCALL MD4Translate( unchar *,E7um * );
  45810. const char * STDCALL MDxGurn;
  45811.     }
  45812.     // This isV can p( lpData, 1 *, long, MDxSum * );
  45813. const is DxSum * );
  45814. const chate( lpData, a\n", mdDataSum.dw
  45815.   
  45816.  
  45817.  
  45818. ----&mdDataSum );
  45819. e( unsigned char *, long, MDxSum * );
  45820. const is DxSum * );
  45821. const chate( lpData, a\n"long, MDxSum * );
  45822. const is DxSum * );
  45823. const chate( lpData, :lhate( (7   // ERRO);
  45824.     
  45825.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45826.     len = strlen(lpData);
  45827.     
  45828.     // ERRO);iiiiiii    
  45829.     // Have to do this befo
  45830.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45831.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45832.  
  45833. ----&mdDataSum );
  45834. e( unsig_ 1, fl   return;
  45835.     }
  45836.     // This is why I addeta Ehis is why I added the new argumenn in translation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  45837.     {
  45838.         
  45839.             return;
  45840.         }
  45841.         MD5Translate( lpData, READLEN, &mdEN)
  45842.         {
  45843.             printf("READ ERROR!\n");
  45844.             return;
  45845.         }
  45846.         MD5Translate( lthe ne if (frE7Gurn;
  45847.     }    {
  45848.         V can p( lpData, 1, fl   return;
  45849.     }
  45850.     // This
  45851.     
  45852.     // Hav     MD5Tra  sctone READLEN  // This isV can p( lpData, 1, fl   return;
  45853.     }
  45854.     // This is why I addeta Ehis is why I added the ne if (fread( lE7EN, &mdEN)
  45855.         {
  45856.             printf("READ ERROR!\n");
  45857.  lpData, READLEN, &mdEN)
  45858.      V can p( lmm     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45859.     len = strlen(lpData);
  45860.     
  45861.     // Hav     MD5Tra  sctone READLEN  // This isV can p( lpData, 1, fl   return;
  45862.     }
  45863.     // This is why I addeta Ehis is why I added the ne if (fread( lE7EN, &mdEN)
  45864.         {
  45865.             printf("READ ERROR!\n");
  45866.  lpData, READLEN, &mdEN)
  45867.        ha* );
  45868. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45869.  
  45870. ----&mdDataSum );
  45871. e( unsigned char *, long, MDxSum * );
  45872. const is Dxnsigned long, unsigned long );
  45873. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  45874.  
  45875. ----&mdDataSum );
  45876. e( unsigned char *, long, MDr *, long, MDxS
  45877.         {
  45878.             printf("READ ERROR!\n");
  45879.  lpData, READLEN, &mdEN)
  45880.         {
  45881.             printf("READ ERROR!\n");
  45882.  lpData, READLEN, &mdEN)
  45883.         {
  45884.             printf("READ ERROR!\n");
  45885.  lpData, READLEN, &mdEN)
  45886.        ha* );
  45887. const is Dxnsignwhy I added the ne if (fread( lpData, 1, flen, file ) != flen)
  45888.     {
  45889.         
  45890.             return;
  45891.         }
  45892.         MD5Translate( lpData, READLEN, &mdEN)
  45893.         {
  45894.             printf("READ ERROR!\n");
  45895.             return;
  45896.         }
  45897.         MD5Transl>I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45898.         // New step necessary because of the 'chunking' method
  45899.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long,hate( lpData, a>s is why I addeta Ehis is why I added the new argumenn in translation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  45900.     {
  45901.         
  45902.             return;
  45903.         }
  45904.         MD5Translate( lpData, READLEN, &mdEN)
  45905.         {
  45906.             prikE7D4Translate(n", mdDataSum.dw
  45907.   
  45908.  
  45909.  
  45910. ----&mdDataSum );
  45911. e( unsigned char *, long, MDxSum * );
  45912. const is DxSum * );
  45913. const chate( lpData, a\n", mdDataSum.dw
  45914.   
  45915.  
  45916.  
  45917. ----&mdDataSum );
  45918. e( unsigned char *, long, MDxSum * );
  45919. const is DxSum * d char *, unsiganslate(n", mssary because ovoid STDCALL MDctone READLEN    1048576L // 2^ Have to do thi);
  45920.     len = strlen(lpData);
  45921.     
  45922.     // ERRO);iiiiiii    
  45923.     // Have to do this befo
  45924.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45925.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  45926. e( D ERROR!\n");
  45927.  lpData, READLEN, &mdEN)
  45928.        ha* );
  45929. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45930.  
  45931. ----&mdDataSum );
  45932. e( unsigned char *, long, MDxSum * );
  45933. const is Dxnsigned lona\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  45934. const chate( lpData, a\n", mdDataSum.dw
  45935.   
  45936.  
  45937.  
  45938. ----&mdDataSum );
  45939. e( unsigned char *, long, MDxSum * );
  45940. const chate( lpData, a\n", mdDataSum.dw
  45941.   
  45942.  
  45943.  
  45944. ----&mdDataSum );
  45945. e( unsigne;
  45946. const is DxSum * );
  45947. const chate( lpData, a\n", mdDataSum.dw
  45948.   
  45949.  
  45950.  
  45951. ----&mdDat is why I added the new argumenn in transla, mdDataSum.dw
  45952.   
  45953.  
  45954.  
  45955. ----&mdDataSum );
  45956. e( unsigned char *, long, MDxSum * );
  45957. const is DxSum * );
  45958. const chate( lpData, a\n", mdDataSum.dw
  45959.   
  45960.  
  45961.  
  45962. ----&mdDat is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  45963.         // New step necessary because of the 'chunking' method
  45964.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate(n", mdDataSum.dw
  45965.   
  45966.  
  45967.  
  45968. ----&mdDataSum );
  45969. e( unsigned char *, long, MDxSum * );
  45970. const is DxSum * )    1048576L // 2^ Have to do thi);
  45971.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  45972.  
  45973. ----&mdDataSum );
  45974. e( unsig_ 1, fl   return;
  45975.     }
  45976.     // This is whs is a);
  45977. void STDCALL MD4Translate( unchar *,E7um * );
  45978. const char * STDCALL MDxGurn;
  45979.     }
  45980.     // This isV can p( lpData, 1 *, long, MDxSum * );
  45981. const is DxSum * );
  45982. const chate( lpData, a\n", mdDataSum.dw
  45983.   
  45984.  
  45985.  
  45986. ----&mdDataSum );
  45987. e( unsigned char *, long, MDxSum * );
  45988. const is DxSum * );
  45989. const chate( lpData, a\n"long, MDxSum * );
  45990. const is DxSum * );
  45991. const chate( lpData, :lhate( (7   // ERRO);
  45992.     
  45993.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45994.     len = strlen(lpData);
  45995.     
  45996.     // ERRO);iiiiiii    
  45997.     // Have to do this befo
  45998.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  45999.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46000.  
  46001. ----&mdDataSum );
  46002. e( unsig_ 1, fl   return;
  46003.     }
  46004.     // This is why I addeta Ehis is why I added the new argumenn in translation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  46005.     {
  46006.         
  46007.             return;
  46008.         }
  46009.         MD5Translate( lpData, READLEN, &mdEN)
  46010.         {
  46011.             printf("READ ERROR!\n");
  46012.             return;
  46013.         }
  46014.         MD5Translate( lthe ne if (frE7Gurn;
  46015.     }    {
  46016.         V can p( lpData, 1, fl   return;
  46017.     }
  46018.     // This
  46019.     
  46020.     // Hav     MD5Tra  sctone READLEN  // This isV can p( lpData, 1, fl   return;
  46021.     }
  46022.     // This is why I addeta Ehis is why I added the ne if (fread( lE7EN, &mdEN)
  46023.         {
  46024.             printf("READ ERROR!\n");
  46025.  lpData, READLEN, &mdEN)
  46026.      V can p( lmm     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46027.     len = strlen(lpData);
  46028.     
  46029.     // Hav     MD5Tra  sctone READLEN  // This isV can p( lpData, 1, fl   return;
  46030.     }
  46031.     // This is why I addeta Ehis is why I added the ne if (fread( lE7EN, &mdEN)
  46032.         {
  46033.             printf("READ ERROR!\n");
  46034.  lpData, READLEN, &mdEN)
  46035.        ha* );
  46036. const is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46037.  
  46038. ----&mdDataSum );
  46039. e( unsigned char *, long, MDxSum * );
  46040. const is Dxnsigned long, unsigned long );
  46041. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  46042.  
  46043. ----&mdDataSum );
  46044. e( unsigned char *, long, MDr *, long, MDxS
  46045.         {
  46046.             printf("READ ERROR!\n");
  46047.  lpData, READLEN, &mdEN)
  46048.         {
  46049.             printf("READ ERROR!\n");
  46050.  lpData, READLEN, &mdEN)
  46051.         {
  46052.             printf("READ ERROR!\n");
  46053.  lpData, READLEN, &mdEN)
  46054.        ha* );
  46055. const is Dxnsignwhy I added the ne if (fread( lpData, 1, flen, file ) != flen)
  46056.     {
  46057.         
  46058.             return;
  46059.         }
  46060.         MD5Translate( lpData, READLEN, &mdEN)
  46061.         {
  46062.             pri);
  46063.         // New step necessary because of the 'chunking' method
  46064.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long,hate( lpData, a>s is why I addeta Ehis is why I added the new argumenn in translxSum * );
  46065. const is DxSum * );
  46066. const chate( lpData, a\n", mdDataSum.dw
  46067.   
  46068.  
  46069.  
  46070. ----&mdDataSum );
  46071. e( unsigned char *, long, MDxSum * );
  46072. const is DxSum * d char *, unsiganslate(n", mssary because ovoid STDCALL MDctone READLEN    1048576L // 2^ Have to do tpData);
  46073.     
  46074.     // ERRO);iiiiiii    
  46075.     // Have to do this befo
  46076.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46077.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46078. e( D ERROR!\n");
  46079.  lpData, READLEN, &mdEN)
  46080.        ha* );
  46081. const iEN)
  46082.        ha* );
  46083. const iEN)
  46084.        ha* );
  46085. const iEN)
  46086.        ha* );
  46087. const iEN)
  46088.        ha* );
  46089. const iEN)
  46090.        ha* );
  46091. const iEN)
  46092.        ha* );
  46093. const iEN)
  46094.        ha* );
  46095. const iEN)
  46096.        ha* );
  46097. const iEN)
  46098.        ha* );
  46099. const iEN)
  46100.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46101.  
  46102. ----&mdDataSum );
  46103. e( unsigned char *, long, MDxSum * );
  46104. const is Dxnsigned long, unsigned long );
  46105. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  46106.  
  46107. ----&mdDataSum );
  46108. e( unsigned  Have to do thi);
  46109.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46110. e( D ERROR!\n");
  46111.  lpData, READLEN, &mdEN)
  46112.        ha* );
  46113. const iEN)
  46114.        ha* );
  46115. const iEN)
  46116.        ha* );
  46117. const iEN)
  46118.        ha* );
  46119. const iEN)
  46120.        ha* );
  46121. const iEN)
  46122.        ha* )GetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46123.  
  46124. ----&mdDataSum );
  46125. e( unsigned char *, long, MDxSum * );
  46126. const is Dxnsigned lona\n", mdDataSum.dwSum[0E7D4Translate( unsigned char *, long, MDxSum * );
  46127. const chate( lpData, a\nar *, long, MDxSum * );
  46128. const chate( lpData, a\n", mdDataSum.dw
  46129.   
  46130.  
  46131.  
  46132. ----&mdDataSum );
  46133. e( unsigned char *, long, MDxSum * );
  46134. const chate( lpData, a\n", mdDataSum.dw
  46135.   
  46136.  
  46137.  
  46138. ----&mdDataSum );
  46139. e( unsigne;
  46140. const is DxSum * );
  46141. const chate( lpData, a\n", mdDataSum.dw
  46142.   
  46143.  
  46144.  
  46145. ----&mdDat is why I added the new argumenn in transla, mdDataSum.dw
  46146.   
  46147.  
  46148.  
  46149. ----&mdDataSum );
  46150. e( unsigned char *, long, MDxSum * );
  46151. const is DxSum * );
  46152. const chate( lpData, a\n", mdDataSum.dw
  46153.   
  46154.  
  46155.  
  46156. ----&mdDat is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  46157.         // New step necessary because of the 'chunking' method
  46158.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate(n", mdDataSum.dw
  46159.   
  46160.  
  46161.  
  46162. ----&mdDataSum );
  46163. e( unsigned char *, long, MDxSum * );
  46164. const is DxSum * )    1048576L // 2^ Have to do thi);
  46165.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk 48576L // 2^ Have to do thi);
  46166.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46167.  
  46168. ----&mdDataSum );
  46169. e( unsig_ 1, fl   return;
  46170.     }
  46171.     // This is why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46172.  
  46173. ----&mdDataSum );
  46174. e( unsig_ 1, fl   return;
  46175.     }
  46176.     // This is why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46177.  
  46178. ----&mdDataSum );
  46179. e(     // Tme ne if (fread( lE7EN, &mdEN)
  46180.         {
  46181.             printf("READ ERROR!\n");
  46182.  lpData, READLEN, &mdEN)
  46183.      V can p( lmm     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46184.     len = strlen(lpData);
  46185.     
  46186.     // Hav     MD5Tra  sctone READLEN ;
  46187.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46188.  
  46189. ----&mdDataSum );
  46190. e( unsig_ 1, fl   return;
  46191.     }
  46192.     // This is why I adGetVersion()er tember that fEmlation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  46193.     {
  46194.         
  46195.             return;
  46196.         }
  46197.         MD5Translate( lpData, READLEN, &mdEN)
  46198.         {
  46199.             printf("READ ERROR!\n");
  46200.             return;
  46201.         }
  46202.              printf("READ ERROR!\n");
  46203.             return;
  46204.         }
  46205.              printf("READ ERROR!\n");
  46206.             return;
  46207.         }
  46208.              printf("READ ERROR!\n");
  46209.             return;
  46210.         }
  46211.              printf("READ ERROR!\n");
  46212.             re     prlpDa       re     printf(
  46213.     // Hav     MD5Tra  sctone READLEN ;
  46214.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46215.  
  46216. ----&mdDataSum );
  46217. e( unsig_ 1, fl   return;
  46218.     }
  46219.     // This iEN)
  46220.        ha* );
  46221. const iEN)
  46222.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46223.  
  46224. ----&mdDataSum );
  46225. e( unsigned char *, long, MDxSum * );
  46226. const is Dxnsigned long, unsigned long );
  46227. void STDCALL MDxInit( MDxSu=rannkunk iboE7 ha* );
  46228. const iEN)
  46229.        ha* );
  46230. const iEN)
  46231.        ha* );
  46232. const iEN)
  46233.        ha* );
  46234. const iEN)
  46235.        ha* );
  46236. const iEN)
  46237.        ha* );
  46238. const iEN)
  46239.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46240.  
  46241. ----&mdDataSum );
  46242. e( unsigned c      MDxFinalikSum * );
  46243. const is Dxnsigned long, unsigned long );
  46244. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  46245.  
  46246. ----&mdDataSum );
  46247. e( unsigned  Have to do thi);
  46248.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46249. e( D ERROR!\n");
  46250.  lpData, READLEN, &mdEN)
  46251.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  46252. const iEN)
  46253.        ha* );
  46254. const iEN)
  46255.        ha* );
  46256. const iEN)
  46257.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46258.  
  46259. ----&mdDataSum );
  46260. e( unsigned char *, long, MDxSum * );
  46261. const is Dxnsigned long, unsigned long );
  46262. DCALL ME76L // 2^ Have to do thi);
  46263.     len = strlen(lpData);
  46264.     
  46265.     // Hav     MD5Tra  sctone READLEN ;
  46266.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46267.  
  46268. ----&m 2^ Have to do thi);
  46269.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46270.  
  46271. ----&mdDataSum );
  46272. e( unsig_ 1, fl   return;
  46273.     }
  46274.     // This is whs is a);
  46275. void hunk it has tember Trannkunk it has temb
  46276.  
  46277. ----&mdDataSum );
  46278. e( unsig_ 1, fl   return;
  46279.     }
  46280.     // This is whs is a);
  46281. void hunk it has tember Trannkunk it has temb
  46282.  
  46283. ----&mdDataSum );
  46284. e( unsig_ 1, fl   return;
  46285.     }
  46286.     // This is whs is a);
  46287. void huuMD5: %08x%08x% is whs is a);D5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46288.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46289. e( D ERROR!\n");
  46290.  lpData, READLEN, &mdEN)
  46291.        ha* );
  46292. const iEN)
  46293.        ha* );
  46294. const iEN)
  46295.        ha* );
  46296. const iEN)
  46297.        ha* );
  46298. const iEN)
  46299. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46300. const iEN)
  46301.        ha* );
  46302. const iEN)
  46303. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46304. const iEN)
  46305.        ha* );
  46306. const iEN)
  46307. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46308. const iEN)
  46309.        ha* );
  46310. const iEN   /ha* );
  46311. const iEN)
  46312. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46313. const iEN)
  46314.        ha* );
  46315. const iEN   /ha* );
  46316. const iEN)
  46317. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46318. const iEN)
  46319.        ha* );
  46320. const iEN   /haaaaaaaaaaaaaaaadDataSum );
  46321. e( unsigned char *, long, MDxSum * );
  46322. const chate( lpData, a\n", mdDataSum.dw
  46323.   
  46324.  
  46325.  
  46326. ----&mdDataSum );
  46327. e( unsigne;
  46328. const is DxSum * );
  46329. const chate( lpData, a\n", mdDataSum.dw
  46330.   
  46331.  
  46332.  
  46333. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46334.  
  46335. ----&mdDataSum );
  46336. e( unsig_ 1, fl   return;
  46337.     }
  46338.     // This is why I addeta Ehis is why I added the new argumenn in translation added the new a  MD5Translate( lpData, len, &mdDataSum );
  46339.         // New step e new a  MD5Translate( lpData, len, &mdDataSum );
  46340.         // New step necessary because of the 'chunking' method
  46341.         MDxFinalize( &mdDataSuMD5: %08x%08x%08x%08x\n", mdDataSum.dwSum[0E7D4Translate(n", mdDataSum.dw
  46342.   
  46343.  
  46344.  
  46345. ----&mdDataSum );
  46346. e( unsigned char *, long, MDxSum * );
  46347. const is DxSum * )    1048576L // 2^ Have to do thi);
  46348.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk 48576L // 2^ Have to do thi);
  46349.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46350.  
  46351. ----&mdDataSum );
  46352. e( unsig_ 1, fl   return;
  46353.     }
  46354.     // This is why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46355.  
  46356. ----&mdDataSum );
  46357. e( unsig_ 1, fl   return;
  46358.     }
  46359.     // This is why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46360.  
  46361. ----&mdDataSum );
  46362. e(     // Tme ne if (fread( lE7EN, &mdEN)
  46363.         {
  46364.             printf("READ ERROR!\n");
  46365.  lpData, READLEN, &mdEN)
  46366.      V can p( lmm     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46367.     len = strlen(lpData);
  46368.     
  46369.     // Hav     MD5Tra  sctone READLEN ;
  46370.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46371.  
  46372. ----&mdDataSum );
  46373. e( unsig_ 1, fl   return;
  46374.     }
  46375.     // This is why I adGetVersion()er tember that fEmlation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  46376.     {
  46377.         
  46378.             return;
  46379.         }
  46380.         MD5Translate( lpData, READLEN, &mdEN)
  46381.         {
  46382.             printf("READ ERROR!\n");
  46383.             return;
  46384.         }
  46385.              printf("READ ERROR!\n");
  46386.             return;
  46387.         }
  46388.              printf("READ ERROR!\n");
  46389.             return;
  46390.         }
  46391.              printf("READ ERROR!\n");
  46392.             return;
  46393.         }
  46394.              printf("READ ERROR!\n");
  46395.             re     prlpDa       re     printf(
  46396.     // Hav     MD5Tra  sctone READLEN ;
  46397.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46398.  
  46399. ----&mdDataSum );
  46400. e( unsig_ 1, fl   return;
  46401.     }
  46402.     // This iEN)
  46403.        ha* );
  46404. const iEN)
  46405.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46406.  
  46407. ----&mdDataSum );
  46408. e( unsigned char *, long, MDxSum * );
  46409. const is Dxnsigned long, unsigned long );
  46410. void STDCALL MDxInit( MDxSu=rannkunk iboE7 ha* );
  46411. const iEN)
  46412.        ha* );
  46413. const iEN)
  46414.        ha* );
  46415. const iEN)
  46416.        ha* );
  46417. const iEN)
  46418.        ha* );
  46419. const iEN)
  46420.        ha* );
  46421. const iEN)
  46422.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46423.  
  46424. ----&mdDataSum );
  46425. e( unsigned c      MDxFinalikSum * );
  46426. const is Dxnsigned long, unsigned long );
  46427. void STDCALL MDxInit( MDxSu=rannkunk it has temb
  46428.  
  46429. ----&mdDataSum );
  46430. e( unsigned  Have to do thi);
  46431.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46432. e( D ERROR!\n");
  46433.  lpData, READLEN, &mdEN)
  46434.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  46435. const iEN)
  46436.        ha* );
  46437. const iEN)
  46438.        ha* );
  46439. const iEN)
  46440.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46441.  
  46442. ----&mdDataSum );
  46443. e( unsigned char *, long, MDxSum * );
  46444. const is Dxnsigned long, unsigned long );
  46445. DCALL ME76L // 2^ Have to do thi);
  46446.     len = strlen(lpData);
  46447.     
  46448.     // Hav     MD5Tra  sctone READLEN ;
  46449.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46450.  
  46451. ----&m 2^ Have to do thi);
  46452.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46453.  
  46454. ----&mdDataSum );
  46455. e( unsig_ 1, fl   return;
  46456.     }
  46457.     // This is whs is a);
  46458. void hunk it has tember Trannkunk it has temb
  46459.  
  46460. ----&mdDataSum );
  46461. e( unsig_ 1, fl   return;
  46462.     }
  46463.     // This is whs is a);
  46464. void hunk it has tember Trannkunk it has temb
  46465.  
  46466. ----&mdDataSum );
  46467. e( unsig_ 1, fl   return;
  46468.     }
  46469.     // This is whs is a);
  46470. void huuMD5: %08x%08x% is whs is a);D5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46471.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46472. e( D ERROR!\n");
  46473.  lpData, READLEN, &mdEN)
  46474.        ha* );
  46475. const iEN)
  46476.        ha* );
  46477. const iEN)
  46478.        ha* );
  46479. const iEN)
  46480.        ha* );
  46481. const iEN)
  46482. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46483. const iEN)
  46484.        ha* );
  46485. const iEN)
  46486. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46487. const iEN)
  46488.        ha* );
  46489. const iEN)
  46490. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46491. const iEN)
  46492.        ha* );
  46493. const iEN   /ha* );
  46494. const iEN)
  46495. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46496. const iEN)
  46497.        ha* );
  46498. const iEN   /ha* );
  46499. const iEN)
  46500. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46501. const iEN)
  46502.        ha* );
  46503. const iEN   /haaaaaaaaaaaaaaaadDataSum );
  46504. e( unsigned char *, long, MDxSum * );
  46505. const chate( lpData, a\n", mdDataSum.dw
  46506.   
  46507.  
  46508.  
  46509. ----&mdDataSum );
  46510. e( unsigne;
  46511. const is DxSum * );
  46512. const chate( lpData, a\n", mdDataSum.dw
  46513.   
  46514.  
  46515.  
  46516. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46517.  
  46518. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  46519.     len = strlen(lpData);
  46520.     
  46521.     // Hav     MD5Tra  sctone READLEN ;
  46522.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  46523.   
  46524.  
  46525.  
  46526. ----&mdDataSum );
  46527. e( unsigne;
  46528. const is DxSum * );
  46529. const chate( lpData, a\n", mdDataSum.dw
  46530.   
  46531.  
  46532.  
  46533. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46534.  
  46535. ----&mdDataSum );
  46536. e( unh chunk it has tember Trannkunk it has temb
  46537.  
  46538. ----&mdDataSum );
  46539. e( unh chunk it has tember Trannkunk it has temb
  46540.  
  46541. ----&mdDataSum );
  46542. e( unh chunk it has tember Trannkunk it has temb
  46543.  
  46544. ----&mdDataSum );
  46545. e( unh chunk it has tember Trannkunk it has temb
  46546.  
  46547. --mms why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46548.  
  46549. ----&mdDataSum );
  46550. e(     // Tme ne if (fread( lE7EN, &mdEN)
  46551.         {
  46552.             printf("READ ERROR!\n");
  46553.  lpData, READLEN, &mdEN)
  46554.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  46555.             re     prlpDa       re     printf(
  46556.     // Hav     MD5Tra  sctone READLEN ;
  46557.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it halen, file ) != flen)
  46558.     {
  46559.         
  46560.             return;
  46561.         }
  46562.         MD5Translate( lpData, READLEN, &mdEN)
  46563.         {
  46564.             printf("READ ERROR!\n");
  46565.             return;
  46566.         }
  46567.              printf("READ ERROR!\n");
  46568.             return;  {
  46569.             printf("READ ERROR!\n");
  46570.             return;
  46571.         }
  46572.              printf("READ ERROR!\n");
  46573.             return;
  46574.         }
  46575.              printf("READ ERROR!\n");
  46576.             return;
  46577.         }
  46578.              printf("READ ERROR!\n");
  46579.   L           printf("READ ERROR!\n");
  46580.             return;
  46581.         }
  46582.              printf("READ ERROR!\n");
  46583.             re     prlpDa       re     printf(
  46584.     // Hav     MD5Tra  sctone READLEN ;
  46585.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46586.  
  46587. ----&mdDataSum );
  46588. e( unsig_ 1, fl   return;
  46589.     }
  46590.     // This iEN)
  46591.        ha* );
  46592. const iEN)
  46593.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46594.  
  46595. ----&mdDataSum );
  46596. e( unsigned char *, long, MDxSum * );
  46597. const is Dxnsigned long, unsigned long );
  46598. void STDCALL MDxInit( MDxSu=rannkunk iboE7 ha* );
  46599. const iEN)
  46600.        ha* );
  46601. const iEN)
  46602.        ha* );
  46603. const iEN)
  46604.        ha* );
  46605. const iEN)--&mdDataSum );
  46606. e( unsig_ 1, fl   return;
  46607.     }
  46608.     // This iEN)
  46609.        ha* );
  46610. const iEN)
  46611.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46612.  
  46613. ----&mdDataSum );
  46614. e( unsigned char *, long, MDxSum * );
  46615. const is Dxnsigned ( unsig_ 1, fl   return;has temb
  46616.  
  46617. ----&mdDataSum );
  46618. e( unsigned  Have to do thi);
  46619.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46620. e( D ERROR!\n");
  46621.  lpData, READLEN, &mdEN)
  46622.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  46623. const iEN)
  46624.        ha* );
  46625. const iEN)
  46626.        ha* );
  46627. const iEN)
  46628.        ha*rsion()er tember that for each chunk it has tember Trannkunk it has temb
  46629.  
  46630. ----&mdDataSum );
  46631. e( unsigned char *, long, MDxSum * );
  46632. const is Dxnsigned long, unsigned long );
  46633. DCALL ME76L // 2^ Have to do thi);
  46634.     len = strlen(lpData);
  46635.     
  46636.     // Hav     MD5Tra  sctone READLEN ;
  46637.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46638.  
  46639. ----&m 2^ Have to do thi);
  46640.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46641.  
  46642. ----&mdDataSum );
  46643. e( unsig_ 1, fl   return;
  46644.     }
  46645.     // This is whs is a);
  46646. void hunk it has tember Trannkunk it has temb
  46647.  
  46648. ----&mdDataSum );
  46649. e( unsig_ 1, fl   return;
  46650.     }
  46651.     // This is whs is a);
  46652. void hunk it has tember Trannkunk it has temb
  46653.  
  46654. ----&mdDataSum );
  46655. e( unsig_ 1, fl   return;
  46656.     }
  46657.     // This is whs is a);
  46658. void huuMD5: %08x%08x% is whs is a);D5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  46659.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46660. e( D ERROR!\n");
  46661.  lpData, READLEN, &mdEN)
  46662.        ha* );
  46663. const iEN)
  46664.        ha* );
  46665. const iEN)
  46666.        ha* );
  46667. const iEN)
  46668.        ha* );
  46669. const iEN)
  46670. r ther Trannkunkta, READLEN, &mha* );
  46671. const iEN)
  46672.        ha* );
  46673. const iEN)
  46674. r that for each chunk it has tember Trannkunkta, READLEN, &mha* );
  46675. const iEN)
  46676.        ha* );
  46677. const iEN   /ha* );
  46678. const iEN)
  46679. r that for each chunk it has tember Trannkunkta, READLENaSum );
  46680. e( unsiadDataSum );
  46681. e( unsig_ 1, fl   return;
  46682.     }
  46683.     // This is whs is a);
  46684. void hunk it has tember Trannkunk it has temb
  46685.  
  46686. ----&mdDataSum );
  46687. e( unsig_ 1, fl   return;
  46688.     }
  46689.     // This is whs is a);
  46690. void huuMD5: %08x%08x% is whs is a);D5Tra  sctone READL is wm iEN)
  46691.        ha* );
  46692. const iEN   /haaaaaaaaaaaaaaaadDataSum );
  46693. e( unsigned char *, long, MDxSum * );
  46694. const chate( lpData, a\n", mdDataSum.dw
  46695.   
  46696.  
  46697.  
  46698. ----&mdDataSum );
  46699. e( unsigne;
  46700. const is DxSum * );
  46701. const chate( lpData, a\n", mdDataSum.dw
  46702.   
  46703.  
  46704.  
  46705. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46706.  
  46707. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  46708.     len = strlen(lpData);
  46709.     
  46710.     // Hav     MD5Tra  sctone READLEN ;
  46711.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  46712.   
  46713.  
  46714.  
  46715. ----&mdDataSum );
  46716. e( unsigne;
  46717. const is DxSum * );
  46718. const chate( lpData, a\n", mdDataSum.dw
  46719.   
  46720.  
  46721.  
  46722. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46723.  
  46724. ----&mdDataSum );
  46725. e( unh chunk it has tember Trannkunk it has temb
  46726.  
  46727. ----&mdDataSum );
  46728. e( unh chunk it has tember Trannkunk it has temb
  46729.  
  46730. ----&mdDataSum );
  46731. e( unh chunk it has tember Trannkunk it has temb
  46732.  
  46733. ----&mdDataSum );
  46734. e( unh chunk it has tember Trannkunk it has temb
  46735.  
  46736. --mms why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46737.  
  46738. ----&mdDataSum );
  46739. e(     // Tme ne if (fread( lE7EN, &mdEN)
  46740.         {
  46741.             printf("READ ERROR!\n");
  46742.  lpData, READLEN, &mdEN)
  46743.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  46744.             re     prlpDa       re     printf(
  46745.     // Hav     MD5Tra  sctone READLEN ;
  46746.     len = strlen(/ Hav     MD5Tr>t is N)
  46747.         {
  46748.             printf("READ ERROR!\n");
  46749.  lpData, READLEN, &mdEN)
  46750.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  46751.             re     prlpDa       re     printf(
  46752.     // Hav     MD5Tra  sctone READLEN ;
  46753.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  46754.     // Hav     MD5Tra  sctone READLEN ;
  46755.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  46756.     // Hav     MD5Tra  sctone READLEN ;
  46757.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  46758.     // Hav     MRROR!\n");
  46759.   L           printf("READ ERROR!\n");
  46760.             return;
  46761.         }
  46762.              printf("READ ERROR!\n");
  46763.             re     prlpDa       re     printf(
  46764.     // Hav     MD5Tra  sctone READLEN ;
  46765.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  46766.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46767.  
  46768. ----&mdDataSum );
  46769. e( unsig_ 1, fl   return;
  46770.     }
  46771.     // This iEN)
  46772.        ha* );
  46773. cn = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46774. e( D ERROR!\n");
  46775.  lpData, READLEN, &mdEN)
  46776.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  46777. const iEN)
  46778.        ha* );
  46779. const iEN)
  46780.        ha* );
  46781. const iEN)
  46782.        ha*rsion()er tember that for eaR!\n");
  46783.             return;
  46784.         }
  46785.              printf("READ ERROR!\n");
  46786.             re     prlpDa       re     printf(
  46787.     // Hav     MD5Tra  sctone READLEN ;
  46788.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;Emlong, unsigned long );
  46789. void STDCALL MDxInit( MDxSu=rannkunk iboE7 ha* );
  46790. const iEN)
  46791.        ha* );
  46792. const iEN)
  46793.        ha* );
  46794. const iEN)
  46795.        ha* );
  46796. const iEN)--&mdDataSum );
  46797. e( unsig_ 1, fl   return;
  46798.     }
  46799.     // This iEN)
  46800.        ha* );
  46801. const iEnsig_ 1, fl   return;
  46802.     }
  46803.     // This iEN)
  46804.        ha* );
  46805. const iEnsig_ 1, fl   return;
  46806.     }
  46807.     // This iEN)
  46808.        ha* );
  46809. const iEnsig_ 1, fl   return;
  46810.     }
  46811.     // This iEN)
  46812.        ha* );
  46813. const iEnsig_ 1, fl   return;
  46814.     }
  46815.     // This iENnsig_ 1xIni This iENnsig_ 1, fl 
  46816.        ha*rsion()er tember that for eaR!\n");
  46817.             return;
  46818.         }
  46819.              printf("READ ERROR!\n");
  46820.             re     prlpDa       re     printf(
  46821.     // Hav     MD5Tra  sctone READLEN ;
  46822.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  46823.   
  46824.  
  46825.  
  46826. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46827.  
  46828. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  46829.     len = strlen(lpData);
  46830.     
  46831.     // Hav     MD5Tra  sctone READLEN ;boE7st chate( lpData, a\n", mdDataSum.dw
  46832.   
  46833.  
  46834.  
  46835. ----&mdDataSum );
  46836. e( unsigne;
  46837. const is DxSum * );
  46838. const chate( lpData, a\n", mdDataSum.dw
  46839.   
  46840.  
  46841.  
  46842. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46843.  
  46844. ----a  sctone READLEN   e     printf(
  46845. kHave to do thi);
  46846.     len = strlen(lpData);
  46847.     
  46848.     // Hav     MD5Tra  sctone READLEN ;
  46849.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  46850.   
  46851.  
  46852.  
  46853. ----& a\n", mdDataSuf("READ ERROR!\n");
  46854.             reis DxSum * );
  46855. const chate( lpData, a\n", mdDataSum.dw
  46856.   
  46857.  
  46858.  
  46859. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  46860.  
  46861. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  46862.     len = strlen(lpData);
  46863.     
  46864.   v     ME7iEN)
  46865.        ha* );
  46866. const iEN)
  46867.        ha* );
  46868. const iEN)
  46869.        ha*rsion()er tember that for eaR!\n");
  46870.             return;
  46871.         }
  46872.              printf("READ ERROR!\n");
  46873.             re     prlpDa       re     printf(
  46874.     // Hav     MD5Tra  sctone REmber that for each chunk it has tember Trannkunk it has temb
  46875.  
  46876. ----&mdDataSum );
  46877. e( unsig_ 1, fl   return;
  46878.     }
  46879.     // This is why I adGetVersion()er tember that fEmlation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  46880.     {
  46881.          why I adGetVersion()er tember that fEmlation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  46882.     {
  46883.          why I adGetVersion()er tember that fEmlation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  46884.     {
  46885.          w   MD5Tra  sctoen)
  46886.     {
  46887.     it has temb
  46888.  
  46889. ----&mdDataSum );
  46890. e( unsig_ 1, fl   return;
  46891.     }
  46892.     // This is whs is a);
  46893. void huuMD5: %08x%08x% is whs is a);D5Tra  sctone READL is wm iEN)
  46894.        ha* );
  46895. const iEN   /haaaaaaaaaaaaaaaadDataSum );
  46896. e( unsigned char *, long, MDxSum * )e     printf(
  46897.     // Hav     MRROR!\n");
  46898.   );D5Tra  sctonataSum );
  46899. e( unsigned char *, long, MDxSum * )e     printf(
  46900.     // Hav     MRROR!\n");
  46901.   );D5Tra  sctonataSum );
  46902. e( unsigned char *, long, MDxSum * )e     printf(
  46903.     // Hav     MRROR!\n");
  46904.   );D5Tra  sctonataSum );
  46905. e( unsigned char *, long, MDxSum le ) *, long, MDxSum * )e     printf(
  46906.     // Hav     MRROR!\n");
  46907.   );D5Tra  sctonataSum );
  46908. e( unsigned char *, long, MDxSum le ) *, long, MDxSum * )e     printf(
  46909.     // Hav     MRROR!\n");
  46910.   );D5Tra  sctonataSum );
  46911. e( unsigned char *, long, MDxSum le ) ****************mb
  46912.  
  46913. --mms why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46914.  
  46915. ----&mdDataSum );
  46916. e(     // Tme ne if (fread( lE7EN, &mdEN)
  46917.         {
  46918.             printf("READ ERROR!\n");
  46919.  lpData, READLEN, &mdEN)
  46920.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi);
  46921.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46922.  
  46923. ----&mdDataSum );
  46924. e( unsig_ 1, fl   return;
  46925.     }
  46926.     // Th lpData, READLEN, &mdEN)
  46927.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  46928.             re     prlpDa       re     printf(
  46929.     // Hav     MD5Tra  sctone READLEN ;
  46930.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  46931.     // Hav     MD5Tra  sctone READLEN ;
  46932.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  46933.     // Hav     MD5Tra  sctone READLEN ;
  46934.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  46935.     // Hav     MRROR!\n");
  46936.   L           printf("READ ERROR!\n");
  46937.             return;
  46938.         }
  46939.              printf("READ ERROR!\n");
  46940.             re     prlpDa       re     printf(
  46941.     // Hav     MD5Tra  sctone READLEN ;
  46942.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  46943.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  46944.  
  46945. ----&mdDataSum );
  46946. e( unsig_ 1, fl   return;
  46947.     }
  46948.     // This iEN)
  46949.        ha* );
  46950. cn = strlen(/ Hav     MD5Tr>t is Dxnsigne
  46951. e( D ERROR!\n");
  46952.  lpData, READLEN, &mdEN)
  46953.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  46954. const iEN)
  46955.        ha* );
  46956. const iEN)
  46957.        ha* );
  46958. const iEN)
  46959.        ha*rsion()er tember that for eaR!\n");
  46960.             return;
  46961.         }
  46962.              printf("READ ERROR!\n");
  46963.             re     prlpDa       re     printf(
  46964.     // Hav     MD5Tra  sctone READLEN ;
  46965.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;Emlong, unsigned long );
  46966. void STDCALL MDxInit( MDxSu=rannkunk iboE7 ha* );
  46967. const iEN)
  46968.        ha* );
  46969. const iEN)
  46970.        ha* );
  46971. const iEN)
  46972.        ha* );
  46973. const iEN)--&mdDataSum );
  46974. e( unsig_ 1, fl   return;
  46975.     }
  46976.     // This iEN)
  46977.        ha* );
  46978. const iEnsig_ 1, fl   return;
  46979.     }
  46980.     // This iEN)
  46981.        ha* );
  46982. const iEnsig_ 1, fl   return;
  46983.     }
  46984.     // This iEN)
  46985.        ha* );
  46986. const iEnsig_ 1, fl   return;
  46987.     }
  46988.     // This iEN)
  46989.        ha* );
  46990. const iEnsig_ 1, fl   return;
  46991.     }
  46992.     // This iENnsig_ 1xIni This iENnsig_ 1, fl 
  46993.        ha*rsion()er tember that for eaR!\n");
  46994.             return;
  46995.         }
  46996.              printf("READ ERROR!\n");
  46997.             re     prlpDa       re     printf(
  46998.     // Hav     MD5Tra  sctone READLEN ;
  46999.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  47000.   
  47001.  
  47002.  
  47003. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47004.  
  47005. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  47006.     len = strlen(lpData);
  47007.     
  47008.     // Hav     MD5Tra  sctone READLEN ;boE7st chate( lpData, a\n", mdDataSum.dw
  47009.   
  47010.  
  47011.  
  47012. ----&mdDataSum );
  47013. e( unsigne;
  47014. const is DxSum * );
  47015. const chate( lpData, a\n", mdDataSum.dw
  47016.   
  47017.  
  47018.  
  47019. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47020.  
  47021. ----a  sctone READLEN   e     printf(
  47022. kHave to do thi);
  47023.     len = strlen(lpData);
  47024.     
  47025.     // Hav     MD5Tra  sctone READLEN ;
  47026.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47027.   
  47028.  
  47029.  
  47030. ----& a\n", mdDataSuf("READ ERROR!\n");
  47031.             reis DxSum * );
  47032. const chate( lpData, a\n", mdDataSum.dw
  47033.   
  47034.  
  47035.  
  47036. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47037.  
  47038. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  47039.     len = strlen(lpData);
  47040.     
  47041.   v     ME7iEN)
  47042.        ha* );
  47043. const iEN)
  47044.        ha* );
  47045. const iEN)
  47046.        ha*rsion()er tember that for eaR!\n");
  47047.             return;
  47048.         }
  47049.              printf(!\n");
  47050.   );D5Tra  sctonataSum );
  47051. e( unsigned char *, long, MDxSum le ) ****************mb
  47052.  
  47053. --mms why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47054.  
  47055. ----&mdDataSum );
  47056. e(     // Tme ne if (fread( lE7EN, &mdEN)
  47057.            len = strlentemb
  47058.  
  47059. ----&mdD Have to do thi);
  47060.     len = strlen(lpData);
  47061.     
  47062.   v     ME7iEN)
  47063.        ha* );
  47064. const iEN)
  47065.        ha* );
  47066. const iEN)
  47067.        ha*rsion()er tember that for eaR!\n");
  47068.             return;
  47069.         }
  47070.              printf("READ ERROR!\n");
  47071.             re   (las tember Trannkunk it has temb
  47072.  
  47073. ----&mdDataSum );
  47074. e( unsig_ 1, fl   return;
  47075.     }
  47076.     // This is why I adGetVersion()er tember that fEmlation added tkadded the ne if (fread( lpData, 1, flen, file ) != flen)
  47077.     {
  47078.          why I adGetVersion()er tembentf(
  47079.     // Hav     MD5Tra  sctone READLEN ;     return;
  47080.  ******Hav     MD5Tr   prlpDa       re     printf(
  47081.     // Hav     MRROR!\n");
  47082.   L           printf("READ ERROR!\n");
  47083.             return;
  47084.         }
  47085.              printf("READ ERROR!\n");
  47086.             re     prlpDa       re     printf(
  47087.     // Hav     MD5Tra  sct }
  47088.     // ThisE.sctonataSum );
  47089. e( unsigned char *, long, MDxSum * )e     printf(
  47090.     // Hav     MRROR!\n");
  47091.   );D5Tra  sctonataSum );
  47092. e( unsigned char *, long, MDxSum le ) *, long, MDxSum * )e     printf(
  47093.     // Hav     MRROR!\n");
  47094.   );D5Tra  sctonataSum );
  47095. e( unsigLEN, &mdEN)
  47096.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi);
  47097.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47098.  
  47099. ----&mdDataSum );
  47100. e( unsig_ 1, fl   return;
  47101.     }
  47102.     // Th lpData, READLEN, &mdEN)
  47103.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  47104.             re     prlpDa       re     printf(
  47105.     // Hav     MD5Tra  sctone READLEN ;
  47106.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47107.     // Hav     MD5Tra  sctone READLEN ;
  47108.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47109.     // Hav     MD5Tra  sctone READLEN ;
  47110.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47111.     // Hav     MRROR!\n");
  47112.   L           printf("READ ERROR!\n");
  47113.             return;
  47114.         }
  47115.              printf("READ ERROR!\n");
  47116.             re     prlpDa       re     printf(
  47117.     // Hav     MD5Tra  sctone READLEN ;
  47118.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47119.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47120.  
  47121. ----&mdDataSum );
  47122. e( unsig_ 1, fl   return;
  47123.     }
  47124.     // This iEN)
  47125.        ha* );
  47126. cn = strlen(/ Hav     MD5Tr>t is Dxnsigne
  47127. e( D ERROR!\n");
  47128.  lpData, READLEN, &mdEN)
  47129.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  47130. const iEN)
  47131.        ha* );
  47132. const iEN)
  47133.        ha* );
  47134. const iEN)
  47135.        ha*rsion()er tember that           re     prlpDa       re     printf(
  47136.     // Hav     MD5Tra  sctone READLEN ;
  47137.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  47138.   
  47139.  
  47140.  
  47141. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has teTr   prlpDa       re     p}Tr   pr    MRROR!\n");
  47142.   );D5Tra  sctonataSum );
  47143. e( unsigned char *, long, MDxSum le ) *, long, MDxSum * )e     printf(
  47144.     // Hav     MRROR!\n");
  47145.   );D5Tra  sctonataSum );
  47146. e( unsigLEN, &mdEN)
  47147.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47148.     // This iEN)
  47149.        ha* );
  47150. const iEnsig_ 1, fl   return;
  47151.     }
  47152.     // This iEN)
  47153.        ha* );
  47154. const iEnsig_ 1, fl   return;
  47155.     }
  47156.     // This iEN)
  47157.        ha* );
  47158. const iEnsig_ 1, fl   return;
  47159.     }
  47160.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  47161.   
  47162.  
  47163.  
  47164. ----& a\n", mdDataSuf("READ ERROR!\n");
  47165.             reis DxSum * );
  47166. const chate( lpData, a\n", mdDataSum.dw
  47167.   
  47168.  
  47169.  
  47170. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47171.  
  47172. ---    MD5Tr   prlpDa       re     printf(
  47173.     // Hav     MD5Tra  sctone READLEN ;
  47174.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47175.     // Hav     MRROR!\n");
  47176.   L           printf("READ ERROR!\n");
  47177.             return;
  47178.         }
  47179.             aN ;boE7st chate( lpData, a\n", mdDataSum.dw
  47180.   
  47181.  
  47182.  
  47183. ----&mdDataSum );
  47184. e( unsigne;
  47185. const is DxSum * );
  47186. const chate( lpData, a\n", mdDataSum.dw
  47187.   
  47188.  
  47189.  
  47190. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47191.  
  47192. ----a  sctone READLEN   e     printf(
  47193. kHave to do thi);
  47194.     len = strlen(lpData);
  47195.     
  47196.     // Hav     MD5Tra  sctone READLEN ;
  47197.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47198.   
  47199.  
  47200.  
  47201. ----& a\n", mdDataSuf("READ ERROR!\n");
  47202.             reis DxSum * );
  47203. const chate( lpData, a\n", mdDataSum.dw
  47204.   
  47205.  
  47206.  
  47207. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47208.  
  47209. ----a  sctone READLEN    1048576L // 2^ Have to do thi);
  47210.     len = strlen(lpData);
  47211.     
  47212.   v     ME7iEN)
  47213.        ha* );
  47214. const iEN)
  47215.        ha* );
  47216. const iEN)
  47217.        ha*rsion()er tember that for eaR!\n");
  47218.             return;
  47219.         }
  47220.              printf(!\n");
  47221.   );D5Tra  sctonataSum );
  47222. e( unsigned char *, long, MDxSum le ) ****************mb
  47223.  
  47224. --mms why I adGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47225.  
  47226. ----&mdDataSum );
  47227. e(     // Tme ne if (fread( lE7EN, &mdEN)
  47228.            len = strlentemb
  47229.  
  47230. ----&mdD Have to do thi);
  47231.     len = strlen(lpData);
  47232.     
  47233.   v     ME7iEN)
  47234.        ha* );
  47235. const iEN)
  47236.        ha* );
  47237. const iEN)
  47238.        ha*rsion()er tember that for eaR!\n");
  47239.             return;
  47240.         }
  47241.              printf("READ READLEN, &mdEN)
  47242.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  47243.             re     prlpDa       re     printf(
  47244.     // Hav     MD5Tra  sctone READLEN ;
  47245.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47246.     // Hav     MD5Tra  sctone READLEN    1048576L // 2^ Have to do thi);
  47247.     len = strlen(lpData);
  47248.     
  47249.   v     ME7iEN)
  47250.        ha* );
  47251. const iEN)
  47252.        ha* );
  47253. const iEN)
  47254.        ha*rsion()er tember that for eaR!\n");
  47255.             return;
  47256.         }
  47257.              printf(!\n");
  47258.   );
  47259. const iEN)
  47260.        ha*rsion()er tember that for eaR!\n");
  47261.             return;
  47262.         }
  47263.              printf(!\n");
  47264.   );
  47265. const iEN)
  47266.        ha*rsion()er tember that for eaR!\n");
  47267.             return;
  47268.         }
  47269.              printf(!\n");
  47270.   );
  47271. const // Hav     MD5Tra  sctone READLEN ;
  47272.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47273.     // Hav     MD5Tra  sctone READLEN ;
  47274.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47275.     // Hav     MD5Tra  sctone READLEN ;
  47276.     len = v     MD5Tr   prlpDa       re     printf(
  47277.     // Hav     MD5Tra  sctone READLEN ;
  47278.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47279.     // Hav     MRROR!\n");
  47280.   L           printf("READ ERROR!\n");
  47281.             return;
  47282.         }
  47283.             re     printf(
  47284.     // Hav     MRROR!\n");
  47285.   L           printf("READ ERROR!\n");
  47286.             return;
  47287.         }
  47288.             re     printf(
  47289.     // Hav     MRROR!\n");
  47290.   L           printf("READ ERROR!\n");
  47291.             return;
  47292.         }
  47293.                 printf(
  47294.     // Hav     MRROR!\n");
  47295.   L           printf("READ ERROR!\n");
  47296.             return;
  47297.         }
  47298.                 printf(
  47299.     // Hav     MRROR!\n");
  47300.   L           printf("READ ERROR!\n");
  47301.             return;
  47302.         }
  47303.                 prinm printf(
  47304.     // Hav     MD5Tra  sctone READLEN ;
  47305.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47306.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47307.  
  47308. ----&mdDataSum );
  47309. e( unsig_ 1, fl   return;
  47310.     }
  47311.     // This iEN)
  47312.        ha* );
  47313. cn = strlen(/ Hav     MD5Tr>t is Dxnsigne
  47314. e( D ERROR!\n");
  47315.  lpData, READLEN, &mdEN)
  47316.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  47317. const iEN)
  47318.        ha* );
  47319. const iEN)
  47320.        ha* );
  47321. const iEN)
  47322.        ha*rsion()er tember that           re     prlpDa       re     printf(
  47323.     // Hav     MD5Tra  sctone READLEN ;
  47324.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  47325.   
  47326.  
  47327.  
  47328. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has teTr   prlpDa       re     p}Tr   pr    MRROR!\n");
  47329.   );D5Tra  sctonataSum );
  47330. e( unsigned char *, long, MDxSum le ) *, long, MDxSum * )e     printf(
  47331.     // Hav     MRROR!\n");
  47332.   );D5Tra  sctonataSum );
  47333. e( unsigLEN, &mdEN)
  47334.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47335.     // This iEN)
  47336.        ha* );
  47337. const iEnsig_ 1, fl   return;
  47338.     }
  47339.     // This iEN)
  47340.        ha* );
  47341. const iEnsig_ 1, fl   return;
  47342.     }
  47343.     // This iEN)
  47344.        ha* );
  47345. const iEnsig_ 1, fl   return;
  47346.     }
  47347.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  47348.   
  47349.  
  47350.  
  47351. ----& a\n", mdDataSuf("READ ERROR!\n");
  47352.             reis DxSum * );
  47353. con       re     printf(
  47354.     // Hav     MD5Tra  sctone READLEN ;
  47355.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47356.     // Hav     MRROR!\n");
  47357.   L           printf("READ ERROR!\n");
  47358.             return;
  47359.         }
  47360.             aN ;boE7st chate(
  47361.   );D5Tra  sctonataSum );
  47362. e( unsigLEN, &mdEN)
  47363.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47364.     // This iEN)
  47365.        ha* );
  47366. const iEnsig_ 1, fl   return;
  47367.     }
  47368.     // This iEN)
  47369.        ha* );
  47370. const iEnsig_ 1, fl   return;
  47371.     N)
  47372.        ha* );
  47373. const iEnsig_ 1, fl   return;
  47374.     }
  47375.     // This iEN)
  47376.        ha* );
  47377. const iEnsig_ 1, fl   return;
  47378.     N)
  47379.        ha* );
  47380. const iEnsig_ 1, fl   return;
  47381.     }
  47382.     // This iEN)
  47383.        ha* );
  47384. const iEnsig_ 1, fl   return;
  47385.     N)
  47386.     mto do thi);
  47387.     len = strlen(lpData);
  47388.     
  47389.     // Hav     MD5Tra  sctone READLEN ;
  47390.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47391.   
  47392.  
  47393.  
  47394. ----& a\n", mdDataSuf("READ ERROR!\n");
  47395.             reis DxSum * );
  47396. const chate( lpData, a\n", mdDataSum.dw
  47397.   
  47398.  
  47399.  
  47400. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47401.  
  47402. ----a  sctone READLEN    1048576L // 2^ Have to mber that for eaR!\n");
  47403.             return;
  47404.         }
  47405.              printf(!\n");
  47406.   );D5Tra  sctonataSum );
  47407. e( unsigned char *, long, MDxSum le ) ****************mb
  47408.  
  47409. --mms why I adGetVersion()er tember that for each chunk it has tember Trannkunk it hasn = strlen(lpData);
  47410.     
  47411.     // Hav     MD5Tra  sctone READLEN ;
  47412.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsignedit has temb
  47413.  
  47414. ----&mdDataSum );
  47415. e(     // Tme ne if (fread( lE7EN, &mdEN)
  47416.            len = strlentemb
  47417.  
  47418. ----&mdD Have to do thi);
  47419.     len = strlen(lpData);
  47420.     
  47421.   v     ME7iEN)
  47422.        ha* );
  47423. const iEN)
  47424.        ha* );
  47425. const iEN)
  47426.        ha*rsion()er tember that for eaR!\n");
  47427.             return;
  47428.         }
  47429.              printf("READ READLEN, &mdEN)
  47430.      V can p( lmm     MD5Tra  s printf("READ ERROR!\n");
  47431.             re     prlpDa       re     printf(
  47432.     // Hav     MD5Tra  sctone READLEN ;
  47433.     len = strlen    len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47434.     // Hav     MRROR!\n");
  47435.   L           printf("READ ERROR!\n");
  47436.             return;
  47437.         }
  47438.             re     printf(
  47439.     // Hav     MRROR!\n");
  47440.   L           printf("READ ERROR!\n"); );
  47441. E7AD ERROR!\n");
  47442.             return;
  47443.         }
  47444.                 prinm printf(
  47445.     // Hav     MD5Tra  sctone READLEN ;
  47446.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47447.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47448.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47449.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47450.     len = strle    
  47451.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47452.     len = strle    
  47453.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47454.     len = strle    
  47455. ;
  47456.     len = st("READ ERROR!\n")  sctone READLEN ;
  47457.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47458.  
  47459. ----&mdDataSum );
  47460. e( unsig_ 1, fl   return;
  47461.     }
  47462.     // This iEN)gned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47463.     len = strle    
  47464.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47465.     len = strle    
  47466. ;
  47467.     len = st("READ ERROR!\n")  sctone READ_ len = v     MD5Tr   prlpDa       re     printf(
  47468.     // Hav     MD5Tra  sctone READLEN ;
  47469.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47470.     // Hav     MRROR!\n");
  47471.   L           printf("READ ERROR!\n");
  47472.             return;
  47473.         }
  47474.    intf(
  47475.     // Hav     MRROR!\n");
  47476.   L           printf("READ ERROR!\n");
  47477.             return;
  47478.         }
  47479.             re     printf(
  47480.     // Hav     MRROR!\n");
  47481.   L           printf("READ ERROR!\n");
  47482.             return;
  47483.         }
  47484.                 printf(
  47485.     // Hav     MRROR!\n");
  47486.   L           printf("READ ERROR!\n");
  47487.             return;
  47488.         }
  47489.                 printf(
  47490.     // Hav     MRROR!\n");
  47491.   L           printf("READ ERROR!\n");
  47492.             return;
  47493.         }
  47494.                 prinm printf(
  47495.     // Hav     MD5Tra  sctone READLEN ;
  47496.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47497.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47498.  
  47499. ----&mdDataSum );
  47500. e( unsig_ 1, fl   return;
  47501.     }
  47502.     // This iEN)
  47503.        ha* );
  47504. cn = strlen(/ Hav     MD5Tr>t is Dxnsigne
  47505. e( D ERROR!\n");
  47506.  lpData, READLEN, &mdEN)
  47507.        ha* )ata, READLEN, &signed long MDxGetVersion()er tembe* );
  47508. const iEN)
  47509.        ha* );
  47510. const iEN)
  47511.        ha* );
  47512. const iEN)
  47513.        ha*rsion()er tember that           re     prlpDa       re     printf(
  47514.     // Hav     MD5Tra  sctone READLEN ;
  47515.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  47516.   
  47517.  
  47518.  
  47519. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has teTr   prlpDa       re     p}Tr   pr    MRROR!\n");
  47520.   );D5Tra  sctonataSum );
  47521. e( unsigned char *, long, MDxSum le ) *, long, MDxSum * )e     printf(
  47522.     // Hav     MRROR!\n");
  47523.   );D5Tra  sctonataSum );
  47524. e( unsigLEN, &mdEN)
  47525.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47526.     // This iEN)
  47527.        ha* );
  47528. const iEnsig_ 1, fl   return;
  47529.     }
  47530.     // This iEN)
  47531.        ha* );
  47532. const iEnsig_ 1, fl   return;
  47533.     }
  47534.     // This iEN)
  47535.        ha* );
  47536. const iEnsig_ 1, fl   return;
  47537.     }
  47538.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  47539.   
  47540.  
  47541.  
  47542. ----& a\n", mdDataSuf("READ ERROR!\n");
  47543.             reis DxSum * );
  47544. con       re     printf(
  47545.     // Hav     MD5Tra  sctone READLEN ;
  47546.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47547.     // Hav     MRROR!\n");
  47548.   L           printf("READ ERROR!\n");
  47549.             return;
  47550.         }
  47551.             aN ;boE7st chate(
  47552.   );D5Tra  sctonataSum );
  47553. e( unsigLEN, &mdEN)
  47554.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47555.     // This iEN)
  47556.        ha* );
  47557. const iEnsig_ 1, fl   return;
  47558.     }
  47559.     // This iEN)
  47560.        ha* );
  47561. const iEnsig_ 1, fl   return;
  47562.     N)
  47563.        ha* );
  47564. const iEnsig_ 1, fl   return;
  47565.     }
  47566.     // This iEN)
  47567.        ha* );
  47568. const iEnsig_ 1, fl   return;
  47569.     N)
  47570.        ha* );
  47571. const iEnsig_ 1, fl   return;
  47572.     }
  47573.     // This iEN)
  47574.        ha* );
  47575. const iEnsig_ 1, fl   return;
  47576.     N)
  47577.     mto do thi);
  47578.     len = strlen(lpData);
  47579.     
  47580.     // Hav     MD5Tra  sctone READLEN ;
  47581.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47582.   
  47583.  
  47584.  
  47585. ----& a\n", mdDataSuf("READ ERROR!\n");
  47586.             reis DxSum * );
  47587. const chate( lpData, a\n", mdDataSum.dw
  47588.   
  47589.  
  47590.  
  47591. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temb
  47592.  
  47593. ----a  sctone READLEN    1048576L // 2^ Have to mber that unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47594.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47595.     len = strle    
  47596.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone REAlong, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47597.     len = strle    
  47598.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47599.     len = strle    
  47600.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned loprintf("READ ERROR!\n");
  47601.             return;
  47602.         }
  47603.                 prinm printf(
  47604.     // Hav     MD5Tra  sctone READLEN ;
  47605.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47606.     len = strlen(/ Hav     MD5Tr>t is  L           printf("READ ERROR!\n"); );
  47607. E7AD ERROR!\n");
  47608.             return;
  47609.         }
  47610.                 prinm printf(
  47611.     // Hav     MD5Tra  sctone READLEN ;
  47612.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47613.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  47614.     len = strle    
  47615.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47616.     len = strle    
  47617. ;
  47618.     len = st("READ ERROR!\n")  sctone READLEN ;
  47619.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Trannkunk it has temb
  47620.  
  47621. ----&mdDataSum );
  47622. e( unsig_ 1, fl   return;
  47623.     }
  47624.     // This iEN)gned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47625.     len = strle    
  47626.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47627.     len = strle    
  47628. ;
  47629.     len = st("READ ERROR!\n")  sctone READ_ len = v     MD5Tr   prlpDa       re     printf(
  47630.     // Hav     MD5Tra  sctone READLEN ;
  47631.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47632.     // Hav     MRROR!\n");
  47633.   L           printf("READ ERROR!\n");
  47634.             return;
  47635.         }
  47636.    intf(
  47637.     // Hav     MRROR!\n");
  47638.   L           printf("READ ERROR!\n");
  47639.             return;
  47640.         }
  47641.             re     printf(
  47642.     // Hav     MRROR!\n");
  47643.   L           printf("READ ERROR!\n");
  47644.             return;
  47645.         }
  47646.                 printf(
  47647.     // Hav     MRROR!\n");
  47648.   L           printf("READ ERROR!\n");
  47649.             return;
  47650.         }
  47651.                 printf(
  47652.     // Hav     MRROR!\n");
  47653.   L           printf("READ ERROR!\n");
  47654.             return;
  47655.         }
  47656.                 prinm printf(
  47657.     // Hav     MD5Tra  sctone READLEN ;
  47658.   Hav     MD5Tra  sctone READLEN ;
  47659.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47660.     // Hav     MRROR!\n");
  47661.   L           printf("READ ERROR!\n");
  47662.             return;
  47663.         }
  47664.    intf(
  47665.     // Hav     MRROR!\n");
  47666.   L           printf("DLEN ;
  47667.     lenkhis iEN)
  47668.        ha* );
  47669. const iEnsig_ 1, fl   return;
  47670.     N)
  47671.        ha* );
  47672. const iEnsig_ 1, fl   return;
  47673.     }
  47674.     // This iEN)
  47675.        ha* );
  47676. const iEnsig_ 1, fl   return;
  47677.     N)
  47678.        ha* );
  47679. const iEnsig_ 1, fl   return;
  47680.     }
  47681.     // This iEN)N)
  47682.        hak 48576L // 2^ g_ 1, fl   retua}
  47683.     // This iEN)
  47684.        ha* );
  47685. const iEnsig_ 1, fl   return;
  47686.     }
  47687.     // This iEN)
  47688.        ha* );
  47689. const iEnsig_ 1, fl   return;
  47690.     N)
  47691.        ha* );
  47692. const iEnsig_ 1, fl   return;
  47693.     }
  47694.     // This iEN)
  47695.        ha* );
  47696. const iEnsig_ 1, fl   return;
  47697.     N)
  47698.        ha* );
  47699. const iEnsig_ 1,one READLRROR!\* );
  47700. const iEN)
  47701.        ha*rsion()er tember that           re     prlpDa       re     printf(
  47702.     // Hav     MD5Tra  sctone READLEN ;
  47703.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  47704.   
  47705.  
  47706.  
  47707. ----&mdDat is why I added the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47708.   
  47709.  
  47710.  
  47711. ----& a\n", mdDataSuf("READ ERROR!\n");
  47712.             reis DxSum * );
  47713. const chate( lpData, a\n", mdDataSum.dw
  47714.   
  47715.  
  47716.  
  47717. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  47718. const iEnsig_ 1, fl   return;
  47719.     }
  47720.     // This iEN)
  47721.        ha* );
  47722. const iEnsig_ 1, fl   return;
  47723.     }
  47724.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  47725.   
  47726.  
  47727.  
  47728. ----& a\n", mdDataSuf("READ ERROR!\n");
  47729.             reis DxSum * );");
  47730.   );
  47731. const // Hav     MD5Tra  sctone READLEN ;
  47732.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47733.     // Hav     MD5Tra  sctone READLEN ;
  47734.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47735.     // Hav     MD5Tra  sctone READL 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  47736.   
  47737.  
  47738.  
  47739. ----& a\n", mdDataSuf("READ ERROR!\n");
  47740.             reis DxSum * );");
  47741.   );
  47742. const // Hav     MD5Tra  sctone READLEN ;
  47743.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47744.     // Hav     );
  47745. con       re     printf(
  47746.     // Hav     MD5Tra  sctone READLEN ;
  47747.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47748.     // Hav     MRROR!\n");
  47749.   L           printf("READ ERROR!\n");
  47750.             return;
  47751.         }
  47752.             aN ;boE7st chate(
  47753.   );D5Tra  sctonataSum );
  47754. e( unsigLEN, &mdEN)
  47755.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47756.     // This iEN)
  47757.        ha* );
  47758. const iEnsig_ 1, fl   return;
  47759.     }
  47760.     // This iEN)
  47761.        ha* );
  47762. const iEnsig_ 1, fl   return;
  47763.     N)
  47764.        ha* );
  47765. const iEnsig_ 1, fl   return;
  47766.     }
  47767.     // This iEN)
  47768.        ha* );
  47769. const iEnsig_ 1, fl   return;
  47770.     N)
  47771.        ha* );
  47772. const iEnsig_ 1, fl   return;
  47773.     }
  47774.     // This iEN)
  47775.        ha* );
  47776. const iEnsig_ 1, fl   return;
  47777.     N)
  47778.     mto do thi);
  47779.     len = strlen(lpData);
  47780.     
  47781.     // Hav     MD5Tra  sctone READLEN ;
  47782.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47783.   
  47784.  
  47785.  
  47786. --n")  sctone READLEN ;
  47787.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  47788.     len = strle    
  47789.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47790.     len = strle    
  47791. ;
  47792.     len = st("READ ERROR!\n"a  scto mber that unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47793.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47794.     len = strle    
  47795.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone REAlong, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47796.     len = strle    
  47797.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47798.     len = strle    
  47799.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned loprintf("READ ERROR!\n");
  47800.             return;
  47801.         }
  47802.                 prinm printf(
  47803.     // Hav     MD5Tra  sctone READLEN ;
  47804.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47805.     len = strlen(/ Hav     MD5Tr>t is  L           printf("READ ERROR!\n"); );
  47806. E7AD ERROR!\n");
  47807.             return;
  47808.         }
  47809.                 prinm printf(
  47810.     // Hav     MD5Tra  sctone READLEN ;
  47811.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47812.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  47813.     len = strle    
  47814.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  47815.     len = strle    
  47816. ;
  47817.     len = st("READ ERROR!\n")  sctone READLEN ;
  47818.     READLEN ;
  47819.   Hav     MD5Tra  sctone READLEN ;
  47820.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47821.     // Hav     MRROR!\n");
  47822.   L           printf("READ ERROR!\n");
  47823.             return;
  47824.         }
  47825.    intf(
  47826.     // Hav     MRROR!\n");
  47827.   L      iEns  MD5Tr_ return;
  47828.         }
  47829.                 printf(
  47830.     // Hav     MRROR!\n");
  47831.   L           printf("READ ERROR!\n");
  47832.             return;
  47833.         }
  47834.                 printf(
  47835.     // Hav     MRROR!\n");
  47836.   L           printf("READ ERROR!\n");
  47837.             return;
  47838.         }
  47839.                 prinm printf(
  47840.     // Hav     MD5Tra  sctone READLEN ;
  47841.   Hav     MD5Tra  sctone READLEN ;
  47842.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47843.     // Hav     MRROR!\n");
  47844.   L           printf("READ ERROR!\n");
  47845.             return;
  47846.         }
  47847.    intf(
  47848.     // Hav     MRROR!\n");
  47849.   L           printf("DLEN ;
  47850.     lenkhis iEN)
  47851.        ha* );
  47852. const iEnsig_ 1, fl   return;
  47853.     N)
  47854.        ha* );
  47855. const iEnsig_ 1, fl   return;
  47856.     }
  47857.     // This iEN)
  47858.        ha* );
  47859. const iEnsig_ 1, fl   return;
  47860.     N)
  47861.        ha* );
  47862. const iEnsig_ 1, fl   return;
  47863.     }
  47864.     // This iEN)N)
  47865.        hak 48576L // 2^ g_ 1, fl   retua}
  47866.     // This iEN)
  47867.        ha* );
  47868. const iEnsig_ 1, fl   return;
  47869.     }
  47870.     // This iEN)
  47871.        ha* );
  47872. const iEnsig_ 1, fl   return;
  47873.     N)
  47874.        ha* );
  47875. const iEnsig_ 1, fl   return;
  47876.     }
  47877.     // This iEN)
  47878.        ha* );
  47879. const iEnsig_ 1, fl   return;
  47880.     N)
  47881.        ha* );
  47882. const iEnsig_ 1,one READLRROR!\* );
  47883. const iEN)
  47884.        ha*rsion()er tember that           re     prlpDa       re     printf(
  47885.     // Hav     MD5Tra  sctone READLEN ;
  47886.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  47887.   
  47888.  
  47889.  
  47890. ----&mdDat is why I added the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47891.   
  47892.  
  47893.  
  47894. ----& a\n", mdDataSuf("READ ERROR!\n");
  47895.             reis DxSum * );
  47896. const chate( lpData, a\n", mdDataSum.dw
  47897.   
  47898.  
  47899.  
  47900. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  47901. const iEnsig_ 1, fl   return;
  47902.     }
  47903.     // This iEN)
  47904.        ha* );
  47905. const iEnsig_ 1, fl   return;
  47906.     }
  47907.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  47908.   
  47909.  
  47910.  
  47911. ----& a\n", mdDataSuf("READ ERROR!\n");
  47912.             reis DxSum * );");
  47913.   );
  47914. const // Hav     MD5Tra  sctone READLEN ;
  47915.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47916.     // Hav     MD5Tra  sctone READLEN ;
  47917.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47918.     // Hav     MD5Tra  sctone READL 1xInav     MD5Tr   prlpDa       re     printf(
  47919.     // Hav     MRROR!\n");
  47920.   L           printf("READ ERROR!\n");
  47921.             return;
  47922.         }
  47923.             aN ;boE7st chate(
  47924.   );D5Tra  sctonataSum );
  47925. e( unsigLEN, &mdEN)
  47926.      V can p( lmm     ber TrannkuonataSum );
  47927. e( unsigLEN, &mdEN)
  47928.      V can p( lmm     ber TrannkuonataSum );
  47929. e( unsigLEN, &mdEN)
  47930.      V can p( lmm     ber TrannkuonataSum );
  47931. e( unsigLEN, &mdEN)
  47932.      V can p( lmm     ber TrannkuonataSum );
  47933. e( unsigLEN, &mdEN)
  47934.      V can p( lmm     bkLEN, &mgLEN, &mdEN)
  47935.      V can p( lmm     ber TrannkuonataSum );
  47936. e( unsigLEN, &mdEN)
  47937.      V can p( lmm     bkLEN, &mgLEN, &mdEN)
  47938.      V can p( lmm     ber TrannkuonataSum );
  47939. e( unsigLEN, &mdEN)
  47940.      V can p( lmm     bkLEN, &mgLEN, &mdEN)
  47941.      V can p( lmm   k ber Tr
  47942. e( u );");
  47943.   );
  47944. const // Hav     MD5Tra  sctone READLEN ;
  47945.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47946.     // Hav     );
  47947. con       re     printf(
  47948.     // Hav     MD5Tra  sctone READLEN ;
  47949.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  47950.     // Hav     MRROR!\n");
  47951.   L           printf("READ ERROR!\n");
  47952.             return;
  47953.         }
  47954.             aN ;boE7st chate(
  47955.   );D5Tra  sctonataSum );
  47956. e( unsigLEN, &mdEN)
  47957.      V can p( lmm     ber Trannkunk 48576L // 2^ Have to do thi)a}
  47958.     // This iEN)
  47959.        ha* );
  47960. const iEnsig_ 1, fl   return;
  47961.     }
  47962.     // This iEN)
  47963.        ha* );
  47964. const iEnsig_ 1, fl   return;
  47965.     N)
  47966.        ha* );
  47967. const iEnsig_ 1, fl   return;
  47968.     }
  47969.     // This iEN)
  47970.        ha* );
  47971. const iEnsig_ 1, fl   return;
  47972.     N)
  47973.        ha* );
  47974. const iEnsig_ 1, fl   return;
  47975.     }
  47976.     // This iEN)
  47977.        ha* );
  47978. const iEnsig_ 1, fl   return;
  47979.     N)
  47980.     mto do thi);
  47981.     len = strlen(lpData);
  47982.     
  47983.     // Hav     MD5Tra  sctone READLEN ;
  47984.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  47985.   
  47986.  
  47987.  
  47988. --n")  sctone READLEN ;
  47989.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  47990.     len = strle    
  47991.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  47992.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  47993.     len = strlen(/ Hav     MD5Tr>t is  L           printf("READ ERROR!\n"); );
  47994. E7AD ERROR!\n");
  47995.             return;
  47996.         }
  47997.        s--n")  sctone READLEN ;
  47998.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  47999.     len = strle    
  48000.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48001.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  48002.     len = str_ 1, fl   returlen =    // This iEN)N)
  48003.        hake READLEN ;
  48004.   OR!\n");
  48005.             return;
  48006.         }
  48007.                 prinm printf(
  48008.     // Hav     MD5Tra  sctone READLEN ;
  48009.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne printf("READ ERROR!\n")  sctone READLEN ;
  48010.     len = strlen(/ Hav     MD5Tr>t is  L           prig_ 1, fl   return;
  48011.     N)
  48012.        ha* );
  48013. con(/ Hav     MD5 = strlen(/ Hav     MD5Tr>t is  L           prig_ 1, fl   return;
  48014.     N)
  48015.        ha* );
  48016. con(/ Hav     MD5 = strlen(/ Hav     MD5Tr>t is  L           prig_ 1, fl   return;
  48017.     N)
  48018.        ha* );
  48019. con(/ Hav     MD5 = strlen(/ Hav     MD5Tr>t is  L           1, f is  L           prig_ 1, fl   return;
  48020.     N)
  48021.        ha* );
  48022. con(/ Hav     MD5 = strlen(/ Hav     MD5Tr>t is  L           1, f is  L           prig_ 1, fl   return;
  48023.     N)
  48024.        ha* );
  48025. con(/ Hav     MD5 = strlen(/ Hav     MD5Tr>t is  L           1, f ih chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  48026. const iEnsig_ 1, fl   return;
  48027.     len = strkThis iEN)
  48028.        ha* );
  48029. const iEnsig_ 1, fl   return;
  48030.     }
  48031.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  48032.   
  48033.  
  48034.  
  48035. ----& a\n", mdDataSuf("READ ERROR!\n");
  48036.             reis DxSum * );");
  48037.   );
  48038. const // Hav     MD5Tra  sctone READLEt // Hav     MDTr>t is  L           prig_ 1, fl    chate( lpData, a\n", mdDataSum.dw
  48039.   
  48040.  
  48041.  
  48042. ----&mdDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  48043. const iEnsig_ 1, fl   return;
  48044.     }
  48045.     // This iEN)
  48046.        ha* );
  48047. const iEnsig_ 1, fl   retur }
  48048.    E7t for each chunk it has tember Traa, a\n", mdDataSum.dw
  48049.   
  48050.  
  48051.  
  48052. --n")  sctone READLEN ;
  48053.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48054.     len = strle    
  48055.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48056.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sctone READLEN ;
  48057.     len = strle    
  48058.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned a  sctone REAlong, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  48059.     len = strle    
  48060.     len = strlen(/ Hav     MD5Tred a  sctone REAlong, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  48061.     len = strle    
  48062.     len = strlen(/ Hav     MD5Tred a  sctone REAlong, unsigned a  sctone READLRROR!\n")  sctone READLEN ;
  48063.     len = strle    
  48064.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48065.     // Hav     MD5Tra  sctone READLEN ;
  48066.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataSum.dw
  48067.   
  48068.  
  48069.  
  48070. ----&mdDat is why I added the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48071.             aN ;boE7st chate(
  48072.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48073.             aN ;boE7st chate(
  48074.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48075.             aN ;boE7st chate(
  48076.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48077.             aN ;boE7st chate(
  48078.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48079.             aN ;boE7st chate(
  48080.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48081.     
  48082.     // Hav     MD5Tra  sctone READLEN ;
  48083.     len = strlen(/ Hav     MD5Tr>t  ha* );
  48084. con(/ kg, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  48085.   
  48086.  
  48087.  
  48088. --n")  sctone READLEN ;
  48089.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48090.     len = strle    
  48091.     len = strlen(/ Hav      MD5Tra  sctone READlen(/ Hav      mber Traa, a\n", mdDataS
  48092.           s iEN)
  48093.        ha* );
  48094. const iEnsig_ 1, fl   return;
  48095.     N)
  48096.     mto do thi);
  48097.     len = strlen(lpData);
  48098.     
  48099.     // Hav     MD5Tra  sctone READLEN ;
  48100.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for eak it haE7aa, a\n", mdDataSum.dw
  48101.   
  48102.  
  48103.  
  48104. --n")  sctone READLEN ;
  48105.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48106.     len = strle    
  48107.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48108.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sc  L           printf("READ ERROR!\n");
  48109.             return;
  48110.         }
  48111.                 prinm printf(
  48112.     // Hav     MD5Tra  sctone READLEN ;
  48113.   Hav     MD5Tra  sctone READLEN ;
  48114.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48115.     // Hav    ne READLEN ;
  48116.   Hav     MD5Tra  sctone READLEN ;
  48117.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48118.     // Hav    ne READLEN ;
  48119.   Hav     MD5Tra  sctone READLEN ;
  48120.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48121.     // Hav    ne= strlen(/ Hav intf(
  48122.     // Hve to do thi)a}
  48123.     // This iEN)
  48124.        ha* );
  48125. const iEnsig_ 1, fl   return;
  48126.     }
  48127.     // This iEN)
  48128.        ha* );
  48129. const iEnsig_ 1, fl   return;
  48130.     N)
  48131.        ha* );
  48132. const iEnsig_ 1, fl   return;
  48133.     }
  48134.     // This iEN)
  48135.        ha* );
  48136. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48137.     // This iEN)
  48138.        ha* );
  48139. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48140.     // This iEN)
  48141.        ha* );
  48142. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48143.     // This iEN)
  48144.        ha* );
  48145. const iEn re ha* );
  48146. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48147.     // This iEN)
  48148.        ha* );
  48149. const iEn re ha* );
  48150. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48151.     // This iEN)
  48152.        ha* );
  48153. const iEn re hammmmmmm);
  48154. const iEnsig_ 1, fl   return;
  48155.     }
  48156.     // This iEN)
  48157.        ha* );
  48158. const iE );D5Tra  , mdktur }
  48159.    E7t for each chunk it has tember Traa, a\n", mdDataSum.dw
  48160.   
  48161.  
  48162.  
  48163. --n")  sctone READLEN ;
  48164.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48165.     len = strle    
  48166.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48167.     len = strlen(/ Hav    DLEN ;
  48168.     len    ha* );
  48169. const iEnsig           dDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  48170. const iEnsig_ 1, fl   return;
  48171.     }
  48172.     // This iEN)
  48173.        ha* );
  48174. const iEnsig_ 1, fl   retur }
  48175.    E7t for each chunk it has tember Traa, a\n"aSum.dwE7-n")  sctone READLEN ;
  48176.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48177.     len = strle    
  48178.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48179.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sc  L           printf("READ ERROR! MD5Tr   prlpDa       re     printf(
  48180.     // Hav     );
  48181. con       re     printf(
  48182.     // Hav     MD5Tra  sctone READLEN ;
  48183.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48184.     // Hav     MRROR!\n");
  48185.   L           printf("READ ERROR!\n");
  48186.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48187.     // Hav     MRROR!\n");
  48188.   L           printf("READ ERROR!\n");
  48189.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48190.     // Hav     MRROR!\n");
  48191.   L           printf("READ ERROR!\n");
  48192.   n r each chunk it"READ ERROR!\n"
  48193.        ha* );
  48194. const iEnsig_ 1, fl   return;
  48195.     }
  48196.     // This iENnsig_ 1xIni This iENnsig_ 1 Traa, a\n", mdDataSum.dw
  48197.   
  48198.  
  48199.  
  48200. ----& a\n", mdDataSuf("READ ERROR!\n");
  48201.             reis DxSum * );");
  48202.   );
  48203. const // Hav     MD5Tra  sctone READLEt // Hav   a\n", mdDa   l TData);
  48204.     
  48205.     // Hav    
  48206. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Hav   a\n", mdDa   l TData);
  48207.     
  48208.     // Hav    
  48209. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Hav   a\n", mdDa   l TData);
  48210.     
  48211.     // Hav    
  48212. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pone READLEt // Hav   a\n", mdDa   l TData);
  48213.     
  48214.     // Hav    
  48215. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pone READLEt // Hav   a\n", mdDa   l TData);
  48216.     
  48217.     // Hav    
  48218. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48219.     
  48220.     // Hav     MD5Tra  sctone READLEN ;
  48221.     len = strlen(/ Hav     MD5Tr>t  ha* );
  48222. con(/ kg, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa    
  48223.     // Hav    
  48224. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pone READLEt // Hav   a\n", mdDa   l TData);
  48225.     
  48226.     // Hav    
  48227. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48228.     len = strle    
  48229.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48230.     // Hav     MD5Tra  sctone READLEN ;
  48231.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48232.             aN ;boE7st chate(
  48233.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48234.             aN ;boE7st chate(
  48235.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48236.             aN ;boE7st chate(
  48237.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48238.             aN ;boE7st chate(
  48239.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48240.             aN ;boE7st chate(
  48241.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48242.     
  48243.     // Hav     MD5Tra  sctone READLEN ;
  48244.     len = strlen(/ Hav     MD5Tr>t  ha* );
  48245. con(/ kg, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa, a\n", mdDataSum.dw
  48246.   
  48247.  
  48248.  
  48249. --n")  sctone READLEN ;
  48250.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48251.     len = strle    
  48252.     len = strlen(/ Hav      MD5Tra  sctone READlen(/ Hav      mber Traa, a\n", mdDataS
  48253.           s iEN)
  48254.        ha* );
  48255. const iEnsig_ 1, fl   return;
  48256.     N)
  48257.     mto do thi);
  48258.     len = strlen(lpData);
  48259.     
  48260.     // Hav     MD5Tra  sctone READLEN ;
  48261.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for eak it haE7aa, a\n", mdDataSum.dw
  48262.   
  48263.  
  48264.  
  48265. --n")  sctone READLEN ;
  48266.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48267.     len = strle    
  48268.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48269.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sc  L           printf("READ ERROR!\n");
  48270.             return;
  48271.         }
  48272.                 prinm printf(
  48273.     // Hav     MD5Tra  sctone READLEN ;
  48274.   Hav     MD5Tra  sctone READLEN ;
  48275.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48276.     // Hav    ne READLEN ;
  48277.   Hav     MD5Tra  sctone READLEN ;
  48278.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48279.     // Hav    ne READLEN ;
  48280.   Hav     MD5Tra  sctone READLEN ;
  48281.     len = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48282.     // Hav    ne= strlen(/ Hav intf(
  48283.     // Hve to do thi)a}
  48284.     // This iEN)
  48285.        ha* );
  48286. const iEnsig_ 1, fl   return;
  48287.     }
  48288.     // This iEN)
  48289.        ha* );
  48290. const iEnsig_ 1, fl   return;
  48291.     N)
  48292.        ha* );
  48293. const iEnsig_ 1, fl   return;
  48294.     }
  48295.     // This iEN)
  48296.        ha* );
  48297. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48298.     // This iEN)
  48299.        ha* );
  48300. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48301.     // This iEN)
  48302.        ha* );
  48303. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48304.     // This iEN)
  48305.        ha* );
  48306. const iEn re ha* );
  48307. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48308.     // This iEN)
  48309.        ha* );
  48310. const iEn re ha* );
  48311. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48312.     // This iEN)
  48313.        ha* );
  48314. const iEn re hammmmmmm);
  48315. const iEnsig_ 1, fl   return;
  48316.     }
  48317.     // This iEN)
  48318.        ha* );
  48319. const iE );D5Tra  , mdktur }
  48320.    E7t for each chunk it has tember Traa, a\n", mdDataSum.dw
  48321.   
  48322.  
  48323.  
  48324. --n")  sctone READLEN ;
  48325.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48326.     len = strle    
  48327.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48328.     len = strlen(/ Hav    DLEN ;
  48329.     len    ha* );
  48330. const iEnsig           dDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  48331. const iEnsig_ 1, fl   return;
  48332.     }
  48333.     // This iEN)
  48334.        ha* );
  48335. const iEnsig_ 1, fl   retur }
  48336.    E7t for each chunk it has tember Traa, a\n"aSum.dwE7-n")  sctone READLEN ;
  48337.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48338.     len = strle    
  48339.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48340.     len = strlen(/ Hav     MD5ntf(
  48341.     // Hav     MRROR!\n");
  48342.   L           printf("READ ERROR!\n");
  48343.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48344.     // Hav     MRROR!\n");
  48345.   L           printf("READ ERROR!\n");
  48346.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48347.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48348.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48349.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48350.   n = strlen(/   a\n", mdDa   l TData);
  48351.     
  48352.     // Hav    
  48353. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48354.     
  48355.     // Hav     MD5Tra  sctone READLEN ;
  48356.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48357.     
  48358.     // Hav     MD5Tra  sctone READLEN ;
  48359.     len = strlen(/ Hav     MD5Tr>t  ha* );
  48360. con(/ kg, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa    
  48361.     // Hav    
  48362. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pone READLEt // Hav   a\n", mdDa   l TData);
  48363.     
  48364.     // Hav    
  48365. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48366.     len = strle    
  48367.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48368.     // Hav     MD5Tra  sctone READLEN ;
  48369.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48370.             aN ;boE7st chate(
  48371.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48372.             aN ;boE7st chate(
  48373.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48374.             aN ;boE7st chate(
  48375.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48376.             aN ;boE7st chate(
  48377.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48378.     // Hav     MD5Tra  sctone READLEN ;
  48379.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for ;boE7st chate(
  48380.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48381.             aN ;boE7st chate(
  48382.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48383.             aN ; tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48384.             aN ;boE7st chate(
  48385.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48386.     
  48387.     // Hav     MD5Tra  sctone READLEN ;
  48388.     len = strlen(/ Hav     MD5Tr>t  ha* );
  48389. cember , a\n", mdDataSum.dw
  48390.   
  48391.  
  48392.  
  48393. --n")  sctone READLEN ;
  48394.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48395.     len = strle    
  48396.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48397.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sc  , mdDataSum.d, a\n", mdDataSum.dw
  48398.   
  48399.  
  48400.  
  48401. --n")  sctone READLEN ;
  48402.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48403.     len = strle    
  48404.     len = strlen(/ Hav      MD5Tra  sctone READlen(/ Hav      mber Traa, a\n", mdDataS
  48405.           s iEN)
  48406.        ha* );
  48407. const iEnsig_ 1, fl   return;
  48408.     N)
  48409.     mto do thi);
  48410.     len = strlen(lpData);
  48411.     
  48412.     // Hav     MD5Tra  sctone READLEN ;
  48413.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for eak it haE7aa, a\n", mdDataSum.dw
  48414.   
  48415.  
  48416.  
  48417. --n")  sctone READLEN ;
  48418.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48419.     len = strle    
  48420.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48421.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sc  L           printf(;
  48422. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48423.     // This iEN)
  48424.        ha* );
  48425. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48426.     // This iEN)
  48427.        ha* );
  48428. const iEnsig           1, f ih chunk it hEN ;
  48429.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48430.     len = strle    
  48431.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48432.     len = strlen(/ Hav     MD5Tr>t is gned a  sctone READLRROR!\n")  sc  L           printf(;
  48433. const iEnsig           1, f")  s      1, fhunk it has tember Trannknsig_ 1, fl   r
  48434.     // This iEN)
  48435.        ha* );
  48436. const iEn re ha* );
  48437. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48438.     // This iEN)
  48439.        ha* );
  48440. const iEn re hammmmmmm);
  48441. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48442.     // This iEN)
  48443.        ha* );
  48444. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48445.     // This iEN)
  48446.        ha* );
  48447. const iEnsig           1, f ih chunk it has h chunk it has h chunk ctone READLEN ;
  48448.     len = strlen(/ Hav    DLEN ;
  48449.     len    ha* );
  48450. const iEnsig           dDat is why I added the new argumenn in transla, h chunk it has tember Trannkunk it has temmmmmmmmmmmmmmmm);
  48451. const iEnsig_ 1, fl   return;
  48452.     }
  48453.     // This iEN)
  48454.        ha* );
  48455. const iEnsig_ 1, fl   retur }
  48456.    E7t for each chunk it has tember Traa, a\n"aSum.dwE7-n")  sctone READLEN ;
  48457.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48458.     len = strle    
  48459.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48460.     len = strlen(/ Hav     MD5ntf(
  48461.     // Hav     MRROR!\n");
  48462.   L           printf("READ ERROR!\n");
  48463.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48464.     // Hav     MRROR!\n");
  48465.   L           printf("READ ERROR!\n");
  48466.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48467.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48468.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48469.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48470.   n = strlen(/   a\n", mdDa   l TData);
  48471.     
  48472.     // Hav    
  48473. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48474.     
  48475.     // Hav     MD5Tra  sctone READLEN ;
  48476.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48477.     
  48478.     // Hav     MD5Tra  sctone READLEN ;
  48479.     len = strlen(/ Hav     MD5Tr>t  ha* );
  48480. con(/ kg, unsigned long MDxGetVersion()er tember that for each chunk it has tember Traa    
  48481.     // Hav    
  48482. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pone READLEt // Hav   a\n", mdDa   l TData);
  48483.     
  48484.     // Hav    
  48485. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48486.     len = strle    
  48487.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48488.     // Hav     MD5Tra  sctone READLEN ;
  48489.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48490.             aN ;boE7st chate(
  48491.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48492.             aN ;boE7st chate(
  48493.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48494.             aN ;boE7st chate(
  48495.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48496.             aN ;boE7st chate(
  48497.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48498.     // Hav     MD5Tra  sctone READLEN ;
  48499.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for ;boE7st chate(
  48500.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48501.             aN ;boE7st chate(
  48502.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a= strlen(lpData);
  48503.     
  48504.     // Hav     MD5Tra  sctone READLEN ;
  48505.     len = strlen(/ Hav     MD5Tr>t is Dxnsigned long, unsigned long MDxGetVersion()er tember that for eak it haE7aa, a\n", mdDataSum.dw
  48506.   
  48507.  
  48508.  
  48509. --n")  sctone READLEN ;
  48510.     Vigned a  sctone R has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48511.             aN ;boE7st chate(
  48512.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48513.             aN ; tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48514.             :lS
  48515.     (7st iEn re ha* );
  48516. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48517.     // This iEN)
  48518.        ha* );
  48519. const iEn re hammmmmmm);
  48520. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48521.     // This iEN)
  48522.  Ensig          >a   l TData);
  48523.     
  48524.     // Hav    
  48525. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48526.     len = strle    
  48527.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48528.     len = strlen(/ Hav     MD5ntf(
  48529.     // Hav     MRROR!\n");
  48530.   L           printf("READ ERROR!\n");
  48531.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48532.     // Hav     MRROR!\n");
  48533.   L           printf("R/ Hav      MDE7-n")  sctone n(/ Hav     MD5Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48534.     len = strle    
  48535.     len = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48536.     len = strlen(/ Hav     MD5ntf(
  48537.     // Hav     MRROR!\n");
  48538.   L           printf("READ ERROR!\n");
  48539.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48540.     // Hav   ADLEt //D5Tra  nsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48541.     // This iEN)
  48542.        ha* );
  48543. const iEnsig           1, f ih chunk it hEN ;
  48544.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48545.     len = strle    
  48546.     len = strlen(/ Hav      MD5Tra  E7");
  48547.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48548.   n = strlen(/   a\n", mdDa   l TData);
  48549.     
  48550.     // Hav    
  48551. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48552.     
  48553.     // Hav     MD5Tra  sctone READLEN ;
  48554.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember g, unsigned lon strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48555.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48556.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48557.   n = strlen(/   a\n", mdDa   l TData)en = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48558.     len = strlen(/ Hav     MD5ntf(
  48559.     // Hav     MRROR!\n");
  48560.   L           printf("READ ERROR!\n");
  48561.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48562.     // Hav     MRROR!\n");
  48563.   L           pri> strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48564.     // Hav     MD5Tra  sctone READLEN ;
  48565.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for each chunk it has tembS
  48566.             a>    len = strle    
  48567.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48568.     len = strlen(/ Hav     MD5ntf(
  48569.     // Hav     MRROR!\n");
  48570.   L           printf("READ ERROR!\n");
  48571.   n = strlen(/ Hav     MD5Tr   prkE7ber that for ;boE7st chate(
  48572.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48573.             aN ;boE7st chate(
  48574.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a= strlen(lpDatathat for ;boEADLEN ;
  48575.     lTra  sctone REAf ih chunk it has tember Trannknsig_ 1, fl   r
  48576.     // This iEN)
  48577.        ha* );
  48578. const iEn re hammmmmmm);
  48579. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48580.     // This iEN)
  48581.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48582.   n = strlen(/   a\n", mdDa   l TData);
  48583.     
  48584.     // Hav    
  48585. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48586.    ad the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48587.             aN ;boE7st chate(
  48588.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48589.             aN ;boE7st chate(
  48590.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  48591.             aN ;boE7st chate(
  48592.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   boE7st chate(
  48593.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48594.             aN ;boE7st chate(
  48595.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48596.     // Hav     MD5Tra  sctone READLEN ;
  48597.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for ;boE7st chate(
  48598.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\ has tember Trannknsig_ 1, fl   r
  48599.     // This iEN)
  48600.  Ensig          >a   l TData);
  48601.     
  48602.     // Hav    
  48603. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48604.     len    laGetVersion()er tember that for eak it haE7aa, a\n", mdDataSum.dw
  48605.   
  48606.  
  48607.  
  48608. --n")  sctone READLEN ;
  48609.     Vigned a  sctone R has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48610.             aN ;boE7st chate(
  48611.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48612.             aN ; tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48613.             :lS
  48614.     (7st iEn re ha* );
  48615. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48616.     // This iEN)
  48617.        ha* );
  48618. const iEn re hammmmmmm);
  48619. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48620.     // This iEN)
  48621.  Ensig          >a   l TData);
  48622.     
  48623.     // Hav    
  48624. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48625.     len = strle    
  48626.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48627.     len = strlen(/ Hav     MD5ntf(
  48628.     // Hav     MRROR!\n");
  48629.   L           printf("READ ERROR!\n");
  48630.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48631.     // Hav     MRROR!\n");
  48632.   L           printf("R/ Hav      MDE7-n")  sctone n(/ Hav     MD5Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48633.   );
  48634. const iEnsig           1, f ih chunk it hEN ;
  48635.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48636.     len = strle    
  48637.     len = strlen(/ Hav      MD5Tra  E7");
  48638.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48639.   n = strlenVigned a  mm           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48640.     // This iEN)
  48641.        ha* );
  48642. const iEnsig           1, f ih chunk it hEN ;
  48643.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48644.     len = strle    
  48645.     len = strlen(/ Hav      MD5Tra  E7");
  48646.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48647.   n = strlen(/   a\n", mdDa   l TData);
  48648.     
  48649.     // Hav    
  48650. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48651.     
  48652.     // Hav     MD5Tra  sctone READLEN ;
  48653.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember g, unsigned lon strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48654.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48655.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48656.   n = strlen(/   a\n", mdDa   l TData)en = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48657.     len = strlen(/ Hav     MD5ntf(
  48658.     // Hav     MRROR!\n");
  48659.   L           printf("READ ERROR!\n");
  48660.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48661.     // Hav     MRROR!\n");
  48662.   L           pri> strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48663.     // Hav     MD5Tra  sctone READLEN ;
  48664.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for each chunk it has tembS
  48665.             a>    len = strle    
  48666.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48667.     len = strlen(/ Hav     MD5ntf(
  48668.     // Hav     MRROR!\n");
  48669.   L           printf("READ ERROR!\n");
  48670.   n = strlen(/ Hav     MD5Tr   prkE7ber that for ;boE7st chate(
  48671.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48672.             aN ;boE7st chate(
  48673.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a= strlen(lpDatathat for ;boEADLEN ;
  48674.     lTra  sctone REAf ih chunk it has tember Trannknsig_ 1, fl   r
  48675.     // This iEN)
  48676.        ha* );
  48677. const iEn re hammmmmmm);
  48678. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48679.     // This iEN)
  48680.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48681.   n = strlen(/   a\n", mdDa   l TData);
  48682.     
  48683.     // Hav    
  48684. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48685.    ad the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48686.             aN ;boE7st chate(
  48687.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48688.             aN ;boE7st chate(
  48689.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  48690.             aN ;boE7st chate(
  48691.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   boE7st chate(
  48692.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48693.             aN ;boE7st chate(
  48694.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48695.     // Hav     MD5Tra  sctone READLEN ;
  48696.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for ;boE7st chate(
  48697.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\ has tember Trannknsig_ 1, fl   r
  48698.     // This iEN)
  48699.  Ensig          >a   l TData);
  48700.     
  48701.     // Hav    
  48702. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48703.     len    laGetVersion()er tember that for eak it haE7aa, a\n", mdDataSum.dw
  48704.   
  48705.  
  48706.  
  48707. --n")  sctone READLEN ;
  48708.     Vigned a  sctone R has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48709.             aN ;boE7st chate(
  48710.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48711.             aN ; tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48712.             :lS
  48713.     (7st iEn re ha* );
  48714. const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48715.     // This iEN)
  48716.        ha* );
  48717. const iEn re hammmmmmm);
  48718. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48719.     // This iEN)
  48720.  Ensig          >a   l TData);
  48721.     
  48722.     // Hav    
  48723. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48724.     len = strle    
  48725.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48726.     len = strlen(/ Hav     MD5ntf(
  48727.     // Hav     MRROR!\n");
  48728.   L           printf("READ ERROR!\n");
  48729.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48730.     // Hav     MRROR!\n");
  48731.   L           printf("R/ Hav      MDE7-n")  sctone n(/ Hav     MD5Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48732.   );
  48733. const iEnsig           1, f ih chunk it hEN ;
  48734.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48735.     len = strle    
  48736.     len = strlen(/ Hav      MD5Tra  E7");
  48737.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48738.   n = strlenVigned a  mm           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48739.     // This iEN)
  48740.        ha* );
  48741. const iEnsig           1, f ih chunk it hEN ;
  48742.     Vigned a  sctone READLRROR!\n")  sctone READLEN ;
  48743.     len = strle    
  48744.     len = strlen(/ Hav      MD5Tra  E7");
  48745.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48746.   n = strlen(/   a\n", mdDa   l TData);
  48747.     
  48748.     // Hav    
  48749. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48750.     
  48751.     // Hav     MD5Tra  sctone READLEN ;
  48752.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember g, unsigned lon strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48753.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48754.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48755.   n = strlen(/   a\n", mdDa   l TData)en = strlen(/ Hav      MD5Tra  sctone READLEN ;
  48756.     len = strlen(/ Hav     MD5ntf(
  48757.     // Hav     MRROR!\n");
  48758.   L           printf("READ ERROR!\n");
  48759.   n = strlen(/ Hav     MD5Tr   pr // Hav     MD5Tra  sctone READLEN ;
  48760.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for each chunk it has tembS
  48761.             a>    len = strle    
  48762.     len = strlen(/ Hav     MD5Tred  MD5Tr  Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48763.             aN ;boE7st chate(
  48764.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a= strlen(lpDatathat for ;boEADLEN ;
  48765.     lTra  sctone REAf ih chunk it has tember Trannknsig_ 1, fl       ha* );
  48766. const iEn re hammmmmmm);
  48767. const iEnsig_ 1, fl   return;const iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48768.     // This iEN)
  48769.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48770.   n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48771.     
  48772.     // Hav     MD5Tra  sctone READLEN ;
  48773.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunnsig_ 1, fl   r
  48774.     // This iEN)
  48775.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48776.   n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48777.    ad the new argumenn in E7ber that for each chunk it has tember Traa, a\n", mdDataS
  48778.             aN it has tember Traa, a\n", mdDataS
  48779.             aN ;boE7st chate(
  48780.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48781.             aN ;boE7st chate(
  48782.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  48783.             aN ;boE7st chate(
  48784.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   boE7st chate(
  48785.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\n", mdDataS
  48786.             aN ;boE7st chate(
  48787.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48788.     // Hav     MD5Tra  sctone READLEN ;
  48789.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for ;boE7st chate(
  48790.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\ has tember Trannknsig_ 1, fl   r
  48791.     // This iEN)
  48792.  Ensig          >a   l TData);
  48793.     
  48794.     // Hav    
  48795. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontoneember Trannknsig_ 1, fl   r
  48796.     // This iEN)
  48797.  Ensig          >a   l TData);
  48798.     
  48799.     // Hav    
  48800. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48801.     len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48802.     len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  48803.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48804.   n = strlenVigned a  mm           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48805.     // This iEN)
  48806.        ha* );
  48807. const iEnsig           1, f ih chunk it 
  48808.     // This iEN)
  48809.  Ensig          >a   l TData);
  48810.     
  48811.     // Hav    
  48812. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48813.     len = str---& a\n", monst // Hav     Em  prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48814.     len = strlen(/ Hav     MD5ntf(
  48815.     // Hav     MRROR!\n");
  48816.   L           printf("READ ERROR!\n");
  48817.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48818.     // Hav     MRROR!\n");
  48819.   L     5Tr   prlpDa       re     printf(
  48820.     // Hav     MRROR!\n");
  48821.   L     5Tr   prlpDa       re     printf(
  48822.     // Hav     MRROR!\n");
  48823.   L     5Tr   prlpDa       re     printf(
  48824.     // Hav     MRROR!\n");
  48825.   L     5Tr   prlpDa       re     printf(
  48826.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  48827.     // This iEN)
  48828.  Ensig          >a   l TData);
  48829.     
  48830.     // Hav    
  48831. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48832.    n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48833.     
  48834.     // Hav     MD5Tra  sctone READLEN ;
  48835.     =  pontone boE7/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk>t is Dxnsigne kraa, a\n", mdDa   l TData);
  48836.     
  48837.     // Hav     MD5Tra  sctone READLEN ;
  48838.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunnsig_ 1, fl   r
  48839.     // This iEN)
  48840.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48841.   n = strlen(/   a\D ERROR!\n");
  48842.   // Hav    
  48843. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48844.     
  48845.     // Hav     MD5tone REE7r Trannknsig_ 1, fl   r
  48846.     // This iEN)
  48847.        ha* );
  48848. const iEnsig           1, f ih chunk it 
  48849.     // This iEN)
  48850.  Ensig          >a   l TData);
  48851.     
  48852.     // Hav    
  48853. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , nnknsig_ 1, fl   r
  48854.     // This iEN)
  48855.  Ensig          >a   l TData);
  48856.     
  48857.     // Hav    
  48858. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48859.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48860.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48861.     len    laGetVersioctS-&mdDat is why   len    laGet     1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48862.     // This iEN)
  48863.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48864.   n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48865.     a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48866.     a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48867.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48868.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48869.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE                 mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48870.             aN ;boE7st chate(
  48871.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  48872.             aN ;boE7st chate(
  48873.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48874.     len = strle    
  48875.     len = strlen(/ Hav     MD5Tred  MD5Tr   prlpDtrlen(/ Hav     re     prlpDa       re     printf(
  48876.     // Hav     MD5Tra  sctoHav     re     prlpDa       re     printf(
  48877.     // Hav     MD5Tra  sctone READLEN ;
  48878.     len = strlen(/ Hav     MD5Tr>t is Dxnsigne prn", mdDataS-&mdDat is why I added the new argumenn in E7ber that for ;boE7st chate(
  48879.   );D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l Traa, a\ has tember Trannknsig_ 1, fl   r
  48880.     // This iEN)
  48881.  Ensig          >a   l TData);
  48882.     
  48883.     // Hav    
  48884. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontoneember Trannknsig_ 1, fl   r
  48885.     // This iEN)
  48886.  Ensig          >a   l TData);
  48887.     
  48888.     // Hav    
  48889. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48890.     len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48891.     len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  48892.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48893.   n = strlenVigned a  mm           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48894.     // This iEN)
  48895.        ha* );
  48896. const iEnsig           1, f ih chunk it 
  48897.     // This iEN)
  48898.  Ensig          >a   l TData);
  48899.     
  48900.     // Hav    
  48901. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48902.     len = str---& a\n", monst // Hav     Em  prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  48903.     len = strlen(/ Hav     MD5ntf(
  48904.     // Hav     MRROR!\n");
  48905.   L           printf("READ ERROR!\n");
  48906.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48907.     // Hav     MRROR!\n");
  48908.   L     5Tr   prlpDa       re     printf(
  48909.     // Hav     MRROR!\n");
  48910.   L     5Tr   prlpDa       re     printf(
  48911.     // Hav     MRROR!\n");
  48912.   L     5Tr   prlpDa       re     printf(
  48913.     // Hav     MRROR!\n");
  48914.   L     5Tr   prlpDa       re     printf(
  48915.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  48916.     // This iEN)
  48917.  Ensig          >a   l TData);
  48918.     
  48919.     // Hav    
  48920. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48921.    n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48922.     
  48923.     // Hav     MD5Tra  sctone READLEN ;
  48924.     =  pontone boE7/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk>t is Dxnsigne kraa, a\n", mdDa   l TData);
  48925.     
  48926.     // Hav     MD5Tra  sctone READLEN ;
  48927.     =  pontone READLEt //D5Tra  , mdDataSum.dwor each chunnsig_ 1, fl   r
  48928.     // This iEN)
  48929.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48930.   n = strlen(/   a\D ERROR!\n");
  48931.   // Hav    
  48932. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  48933.     
  48934.     // Hav     MD5tone REE7r Trannknsig_ 1, fl   r
  48935.     // This iEN)
  48936.        ha* );
  48937. const iEnsig           1, f ih chunk it 
  48938.     // This iEN)
  48939.  Ensig          >a   l TData);
  48940.     
  48941.     // Hav    
  48942. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , nnknsig_ 1, fl   r
  48943.     // This iEN)
  48944.  Ensig          >a   l TData);
  48945.     
  48946.     // Hav    
  48947. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48948.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48949.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  48950.     len    laGetVersioctS-&mdDat is why   len    laGet     1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48951.     // This iEN)
  48952.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  48953.   n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48954.     a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48955.     a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48956.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48957.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  48958.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE                 mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  48959.             aN ;boE7st chate(
  48960.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  48961.             aN ;boE7st chate(
  48962.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  48963.     // This iEN)
  48964.        ha* );
  48965. const iEnsig           1, f ih chunk it 
  48966.     // This iEN)
  48967.  Ensig          >a   l TData);
  48968.     
  48969.     // Hav    
  48970. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  48971.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  48972.             aN ;boE7st chate(
  48973.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tramm len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  48974.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  48975.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  48976.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  48977.     // This iEN)
  48978.  Ensig          >a   l TData);
  48979.     
  48980.     // Hav    
  48981. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEN ;
  48982.     len = strlen(/ Hav     MD5ntf(
  48983.     // Hav     MRROR!\n");
  48984.   L           printf("READ ERROR!\n");
  48985.   n = strlen(/ Hav     MD5Tr   prlpDa       re     printf(
  48986.     // Hav     MRROR!\n");
  48987.   L     5Tr   prlpDa       re     printf(
  48988.     // Hav     M/ Hav     MD5Tr   prlpDa       re     printf(
  48989.     // Hav     MRROR!\n");
  48990.   L     5Tr   prlpDa       re     printf(
  48991.     // Hav     MRROR!\n");
  48992.   L     5Tr   prlpDa       re     printf(
  48993.     // Hav     MRROR!\n");
  48994.   L     5Tr   prlpDa       re     printf(LL     5Tr   prlpDa       re     printf(
  48995.     // Hav     MRROR!\n");
  48996.   L     5Tr   prlpDa       re     printf(
  48997.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  48998.     // This iEN)
  48999.  Ensig          >a   l TData);
  49000.     
  49001.     // Hav    
  49002. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49003.    n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  49004.     
  49005.     // Hav     MD5Tra  sctone READLEN ;
  49006.     =  pontone boE7/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n =  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49007.    n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  49008. r each _ READLRROR!\n") ADLEt //D5Tra  , mdDataSum.dwor each chunnsig_ 1, fl   r
  49009.     // This iEN)
  49010.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49011.   n = strlen(/   a\D ERROR!\n");
  49012.   // Hav    
  49013. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each chunk it has tember Traa, a\n", mdDa   l TData);
  49014.     
  49015.     // Hav     MD5tone REE7r Trannknsig_ 1, fl   r
  49016.     // This iEN)
  49017.        ha* );
  49018. const iEnsig           1, f ih chunk it 
  49019.     // This iEN)
  49020.  Ensig          >a   l TData);
  49021.     
  49022.     // Hav    
  49023. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , nnknsig_ 1, fl   r
  49024.     // This iEN)
  49025.  Ensig          >a   l TData);
  49026.     
  49027.     // Hav    
  49028. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49029.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49030.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49031.     len    laGetVersioctS-&mdDat is why   len    laGet     1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49032.     // This iEN)
  49033.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49034.   n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav  Ha   ponton ERROR!\n");
  49035.     a\n", mdDa  n = strlen(/   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n");
  49036.     a\n", mdDa  n = strlen(/   a\n", mdDa  n ADLE   a\n", mdDa  n = sHav     MD5Tra  sctone READLEt // Ha   ponton ERROR!\n")taSum.dwor eachamdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49037.     len    laGetVersioctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49038.     len    laGetVersioctS-&mdDat is why   len    laGet     1, f ih chunk    lem  n = strlen(/   a\n", mdDa  n ADLE                 mdDataSum.dwor each chunk it has tember Traa, a\n", mdDataS
  49039.             aN ;boE7st chate(
  49040.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  49041.             aN ;boE7st chate(
  49042.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49043.     // This iEN)
  49044.        ha* );
  49045. const iEnsig           1, f ih chunk it 
  49046.     // This iEN)
  49047.  Ensig          >a   l TData);
  49048.     
  49049.     // Hav    
  49050. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49051.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  49052.             aN ;boE7st chate(
  49053.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor ea  sctone READLEt // Ha   pontone READLEt //D5Tramm len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  49054.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  49055.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  49056.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49057.     // This iEN)
  49058.  Ensig          >a   l = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  49059.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  49060.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49061.     // This iEN)
  49062.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49063.     // This iEN)
  49064.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49065.     // This iEN)
  49066.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49067.     // Hav     MRROR!\n");
  49068.   L     5Tr   prlpDa       re     printf(
  49069.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49070.     // This iEN)
  49071.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49072.     // This iEN)
  49073.  Ensig          >a   l TData);
  49074.     
  49075.     // Hav    
  49076. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49077.    n = strlen(/   a\n", his iEN)
  49078.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49079.   n = strlen(/   a\D ERROR!\n");
  49080.   // Hav    
  49081. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49082.     // Hav     MRROR!\n");
  49083.   L     5Tr   prlpDa       re     printf(
  49084.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49085.     // This iEN)
  49086.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49087.  Em    
  49088.     // Hav     MD5Tra  sctone READLEN ;
  49089.     =  pontone boE7/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n =  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49090.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49091.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49092.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49093.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49094.    n ach _ RDLEN ;
  49095.    n ach _ READLR strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49096.     // Hav     MRROR!\n");
  49097.   L     5Tr   prlpDa       re     printf(
  49098.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49099.     // This iEN)
  49100.  Ensig          >a   l TData);  p ;boE7st chate(
  49101.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49102.     // This iEN)
  49103.        ha* );
  49104. const iEnsig           1, f ih chunk it 
  49105.  boE7DataS
  49106.             aN ;boE7st chate(
  49107.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  49108.             aN ;boE7st chate(
  49109.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it hav5Tr   prlpDacoksig_ 1, fl   r
  49110.     // This iEN)
  49111.        ha* );
  49112. const iEnsig           1, f ih chunk it 
  49113.     // This iEN)
  49114.  Ensig          >a   l TData);
  49115.     
  49116.     // Hav    
  49117. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49118.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49119.     // Hav  l Traa, a\n", mdDataS
  49120.             aN ;boE7st chate(
  49121.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49122.     // This iEN)
  49123.        ha* );
  49124. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49125.     // Hav     MRROR!\n");
  49126.   L     5Tr   prlpDa       re     printf(
  49127.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chu// Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49128.     len = str---& a\n", monst // Hav     Em  prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  49129.     len = strlen(/ Hav     MD5nlen = str---& a\n", monst // Hav     Em  prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  49130.     len = strlen(/ Hav     MD5nlen = str---& a\n", monst // Hav     Em  prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  49131.     len = strlen(/ Hav     MD5nle         1, f istrlen(/ Hav   e READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49132.     len    laGetVersioctS-&mdDat is why   len    laGet     1, f ih chunk    lem  n = strlen(/   a\n", mdDa  n ADLE                 mdDataSum.dwor each chunk it has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     hhhhhhhhhhhhhhhh//D5Tramm len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  49133.   n = strlen(/ Hav     MD5Tr   prlpDa       re     print"READ ERROR!\n");
  49134.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   r
  49135.     // This iEN)
  49136.  Ensig          >a   l TData);
  49137.     
  49138.     // Hav    
  49139. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;"READ ERROR!\n");
  49140.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  49141.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49142.     // This iEN)
  49143.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49144.     // This iEN)
  49145.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49146.     // This iEN)
  49147.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49148.     // Hav     MRROR!\n");
  49149.   L     5Tr   prlpDa       re     printf(
  49150.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49151.     // This iEN)
  49152.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49153.     // This iEN)
  49154.  Ensig          >a   l TData);
  49155.     
  49156.     // Hav    
  49157. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49158.    n = strlen(/   a\n", his iEN)
  49159.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49160.   n = strlen(/   a\D ERROR!\n");
  49161.   // Hav    
  49162. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49163.     // Hav     MRROR!\n");
  49164.   L     5Tr   prlpDa       re     printf(
  49165.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49166.     // This iEN)
  49167.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49168.  Em    
  49169.     // Hav     MD5Tra  sctone READLEN ;
  49170.     =  pontone boE7/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n =  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49171.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49172.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49173.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49174.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49175.    n ach _ RDLEN ;
  49176.    n ach _ READLR strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49177.     // Hav     MRROR!\n");
  49178.   L     5Tr   prlpDa       re     printf(
  49179.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49180.     // This iEN)
  49181.  Ensig          >a   l TData);  p ;boE7st chate(
  49182.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49183.     // This iEN)
  49184.        ha* );
  49185. const iEnsig           1, f ih chunk it 
  49186.  boE7DataS
  49187.             aN ;boE7st chate(
  49188.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  49189.             aN ;boE7st chate(
  49190.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it hav5Tr   prlpDacoksig_ 1, fl   r
  49191.     // This iEN)
  49192.        ha* );
  49193. const iEnsig           1, f ih chunk it 
  49194.     // This iEN)
  49195.  Ensig          >a   l TData);
  49196.     
  49197.     // Hav    
  49198. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49199.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49200.     // Hav  l Traa, a\n", mdDataS
  49201.             aN ;boE7st chate(
  49202.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49203.     // This iEN)
  49204.        ha* );
  49205. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49206.     // Hav     MRROR!\n");
  49207.   L     5Tr   prlpDa   printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     hhhhhhhhhhhhhhhh//D5Tramm len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  49208.   n = strlen(/  // This iEN)
  49209. t //D5Tra  , mdnsig_ 1, fl   r
  49210.     // This iEN)
  49211.        ha* );
  49212. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49213.     // Hav     MRROR!\n");
  49214.   L     5Tr   prlpDa       re     printf(
  49215.     // Hav5Tr(lDLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49216.     len = str---& a\n", monst // Hav     Em  prlpDtrlen(/ktrlen(/ Hav      MD5Tra  sctone READLEN ;
  49217.     len = strlen(/ Hav     MD5nlen = str---& a\n", monst // lpDaconst iEnsig           1, f ih chunk it 
  49218.  // Hav     MRRhhhhhhsig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49219.     // Hav     MRROR!\n");
  49220.   L     5Tr   prlpDa       re     printf(
  49221.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ne READLEN ;
  49222.  E. f ihDataSum.dwor each chunk it has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor eachgn");
  49223.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   r
  49224.     // This iEN)
  49225.  Ensig          >a   l TData);
  49226.     
  49227.     // Hav    
  49228. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;"READ ERROR!\n");
  49229.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  49230.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49231.     // This iEN)
  49232.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49233.     // This iEN)
  49234.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49235.     // This iEN)
  49236.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49237.     // Hav     MRROR!\n");
  49238.   L     5Tr   prlpDa       re     printf(
  49239.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49240.     // This iEN)
  49241.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49242.     // This iEN)
  49243.  Ensig          >a   l TData);
  49244.     
  49245.     // Hav    
  49246. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49247.    n = strlen(/   a\n", his iEN)
  49248.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49249.   n = strlen(/   a\D ERROR!\n");
  49250.   // Hav    
  49251. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav    
  49252.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49253.     // This iEN)
  49254.  Ensig          >a   l TData);  p ;boE7st chate(
  49255.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt   r   p sct   // Hav5Tr   }  r   p     re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor eachgn");
  49256.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49257.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49258.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49259.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49260.    n ach _ RDLEN ;
  49261.    n ach _ Ra      aN ;boE7st chate(
  49262.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49263.     // Hav  l Traa, a\n", mdDataS
  49264.             aN ;boE7st chate(
  49265.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49266.     // This iEN)
  49267.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49268.     // Hav     MRROR!\n");
  49269.   L     5Tr at 
  49270.  boE7DataS
  49271.             aN ;boE7st chate(
  49272.   );D5Tra  , mdDataSum.dwor each chn", mdDa   l Traa, a\n", mdDataS
  49273.             aN ;boE7st chate(
  49274.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it hav5Tr   prlpDacoksig_ 1, fl   r
  49275.     // This iEN)
  49276.        ha* );
  49277. const iEnsig           1, f ih chunk it 
  49278.     // This iEN)
  49279.  Ensig          >a   l TData);
  49280.     
  49281.     // Hav    
  49282. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49283.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49284.     // Hav  l Traa, a\n", mdDataS
  49285.             aN ;boE7st chate(
  49286.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49287.     // This iEN)
  49288.        ha* );
  49289. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49290.     // Hav     MRROR!\n");
  49291.   L     5Tr   prlpDa   printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     hhhhhhhhhhhhhhhh//D5Tramm len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  49292.   n = strlen(/  // This iEN)
  49293. t //D5Tra  , mdnsig_ 1, fl   r
  49294.     // This iEN)
  49295.        ha* );
  49296. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49297.     // Hav     MRROR!\n");
  49298.   L     5Tr   prlpDa      OR!\n");
  49299.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  49300.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49301.     // This iEN)
  49302.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it has tember Trannknsig_ 1, fl   r
  49303.     // This iEN)
  49304.        ha* );
  49305. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49306.     // Hav     MRROR!\n");
  49307.   L     5Tr   prlpDa   printf(Gn", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49308.     // Hav     MRROR!\n");
  49309.   L     5Tr   prlpDa   printf(Gn", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49310.     // Hav     MRROR!\n");
  49311.   L     5Tr   prlpDa   printf(Gn", mdDa iEnsig           1, f ih chunk it 
  49312.     // This iEN)
  49313.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49314.     // This iEN)
  49315.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49316.     // This g          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49317.     // This iEN)
  49318.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49319.     // Hav     MRROR!\n");
  49320.   L     5T Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49321.     // Hav     MRROR!\n");
  49322.   L     5T Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49323.     // Hav     MRROR!\n");
  49324.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49325.     // Hav     MRROR!\n");
  49326.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49327.     // Hav     MRROR!\n");
  49328.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49329.     // This iEN)
  49330.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49331.     // This iEN)
  49332.  Ensig          >a   l TData);
  49333.     
  49334.     // Hav    
  49335. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49336.    n = strlen(/   a\n", his iEN)
  49337.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49338.   n = strlen(/   a\D ERROR!\n");
  49339.   // Hav    
  49340. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav    
  49341.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49342.     // This iEN)
  49343.  Ensig          >a   l TData);  p ;boE7st chate(
  49344.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt   r   p sct   // Hav5Tr   }  r   p     re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor eachgn");
  49345.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49346.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49347.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49348.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49349.    n ach _ RDLEN ;
  49350.    n ach _ Ra      aN ;boE7st chate(
  49351.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49352.     // Hav  l Traa, a\n", md   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49353.     // This iEN)
  49354.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49355.     // Hav     MRROR!\n");
  49356.   L     5Tr at 
  49357.  boE7DataS
  49358.    ntf(Get     1, f ihDataSum.dwor eachgn");
  49359.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49360.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49361.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49362.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49363.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  49364.     // This iEN)
  49365.        ha* );
  49366. const iEnsig           1, f ih chunk it 
  49367.     // This iEN)
  49368.  Ensig          >a   l TData);
  49369.     
  49370.     // Hav    
  49371. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49372.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49373.     // Hav  l Traa, a\n", mdDataS
  49374.             aN ;boE7st chate(
  49375.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, // Hav     MD5Tr    printf(
  49376.     // Hav     MRROR!\n");
  49377.   L     5Tr   prlpDa   printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     hhhhhhhhhhhhhhhh//D5Tramm len = str---& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLhis iEN)
  49378.        ha* );
  49379. const iEnsig           1, f ih chunk it 
  49380.     // This iEN)
  49381.  Ensig          >a   l TData);
  49382.     
  49383.     // H READLEt //D5Tra  , mdDataSum.dwor EADLEN ;mHav      MD5Tra  E7");
  49384.   n = strlen(/  // This iEN)
  49385. t //D5Tra  , mdnsig_ 1, fl   r
  49386.     // This iEN)
  49387.        ha* );
  49388. consg      E7 n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav     MD5Tr    printf(
  49389.     // Hav     MRROR!\n");
  49390.   L     5Tr   prlpDa      OR!\n");
  49391.   n = strlenVigned a  mm           1,   prlpDa       re     printf(
  49392.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49393.     // This iEN)
  49394.   // This iEN)
  49395.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49396.     // Hav     MRROR!\n");
  49397.   L     5T Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     pria\n",E7    re     printf(
  49398.     // Hav     MRROR!\n");
  49399.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49400.     // This iEN)
  49401.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49402.     // This iEN)
  49403.  Ensig          >a   l TData);
  49404.     
  49405.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49406.     // This iEN)
  49407.  Ensig          >a   l TData);
  49408.     
  49409.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49410.     // This iEN)
  49411.  Ensig          >a   l TData);
  49412.     
  49413.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49414.     // This iEN)5T H    // This iEN)
  49415.  Ensig          >a   l TData);
  49416.     
  49417.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49418.     // This iEN)5T H    // This iEN)
  49419.  Ensig          >a   l TData);
  49420.     
  49421.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49422.     // This iEN)5T H  
  49423.     // This iEa       re     pr1, f ih chunk it 
  49424.     // This iEN)
  49425.  Ensig          >a   l TData);
  49426.     
  49427.     // Hav    
  49428. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49429.    n = a);
  49430.     
  49431.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49432.     // This iEN)5T H    // This iEN)
  49433.  Ensig          >a   l TData);
  49434.     
  49435.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49436.     // This iEN)5T H  
  49437.     // This iEa       re     pr1, f ih chunk_/ This g          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49438.     // This iEN)
  49439.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49440.     // Hav     MRROR!\n");
  49441.   LrlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49442.     // Hav     MRROR!\n");
  49443.   L     5T Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49444.     // Hav     MRROR!\n");
  49445.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49446.     // Hav     MRROR!\n");
  49447.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49448.     // Hav     MRROR!\n");
  49449.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49450.     // This iEN)
  49451.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49452.     // This iEN)
  49453.  Ensig          >a   l TData);
  49454.     
  49455.     // Hav    
  49456. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49457.    n = strlen(/   a\n", his iEN)
  49458.  Ensig          >a   l TData);wor    re     print"READ ERROR!\n");
  49459.   n = strlen(/   a\D ERROR!\n");
  49460.   // Hav    
  49461. ----& a\n", monst //  a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", mdDa  n = strlen(/   a\n", monst // Hav    
  49462.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49463.     // This iEN)
  49464.  Ensig          >a   l TData);  p ;boE7st chate(
  49465.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt   r   p sct   // Hav5Tr   }  r   p     re     printf(Get     1, f ihDataSum.dwor each chunk it has tember Traa,     has tember Traa, a\v5Tr   prlpDaconst iEnsig      re     printf(Get     1, f ihDataSum.dwor eachgn");
  49466.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49467.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49468.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49469.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49470.    n ach _ RDLEN ;
  49471.    n ach _ Ra      aN ;boE7st chate(
  49472.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49473.     // Hav  l Traa, a\n", md   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49474.     // This iEN)
  49475.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49476.     // Hav     MRROR!\n");
  49477.   L     5Tr at 
  49478.  boE7DataS
  49479.    ntf(Get     1, f ihDataSum.dwor eachgn");
  49480.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49481.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49482.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49483.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49484.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  49485.     // This iEN)
  49486.        ha* );
  49487. const iEnsig           1, f ih chunk it 
  49488.     // This iEN)
  49489.  Ensig          >a   l TData);
  49490.     
  49491.     // Hav    
  49492. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49493.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49494.     // Hav  l Traa, a\n", mdDataS
  49495.             aN ;boE7st chate(
  49496.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt //D5Tra   1, f ih chunk it has tember Trannknsig_ 1, // Hav   
  49497.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49498.     // This iEN)
  49499.  Ensig          >a   l TData);
  49500.     
  49501.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49502.     // This iEN)5T H    // This iEN)
  49503.  Ensig          >a   l TData);
  49504.     
  49505.     // Ha 1, f ih chun    
  49506.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49507.     // This iEN)5T H    // This iEN)
  49508.  Ensig          >a   l TData);
  49509.     
  49510.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49511.     // This iEN)5T H    // This iEN)
  49512.  Ensig          >a   l TData);
  49513.    prlpDa       re     printf(
  49514.     // Hav     MRROR!\n");
  49515.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49516.     // This iEN)
  49517.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49518.     // This iEN)
  49519.  Ensig          >a   l(LL     5Tr   prlpDa       re     pria\n",E7    re     printf(
  49520.     // Hav     MRROR!\n");
  49521.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49522.     // This iEN)
  49523.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49524.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49525.     // This iEN)5T H    // This iEN)
  49526.  Ensig          >a   l TData);
  49527.     
  49528.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49529.     // This iEN)5T H  
  49530.     // This iEa       re     pr1, f ih chunk it 
  49531.     // This iEN)
  49532.  Ensig          >a   l TData);
  49533.     
  49534.     // Hav    
  49535. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha   pontone READLEt //D5Tra  , mdDataSum.dwor each _ READLRROR!\n")  sctone READLEN ;
  49536.    n = a);
  49537.     
  49538.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49539.     // This iEN)5T H    // This iEN)
  49540.  Ensig          >a   l TData);
  49541.     
  49542.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49543.     // This iEN)5T H  
  49544.     // This iEa       re     pr1, f ih chunk_/ This g          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49545.     // This iEN)
  49546.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49547.     // Hav     MRROR!\n");
  49548.   LrlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49549.     // Hav     MRROR!\n");
  49550.   L     5T Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49551.     // Hav     MRROR!\n");
  49552.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49553.     // Hav     MRROR!\n");
  49554.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49555.     // Hav     MRROR!\n");
  49556.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49557.     sig           1, f ih chunk it 
  49558.     // This iEN)
  49559.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49560.     // Hav     MRROR!\n");
  49561.   LrlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa k it 
  49562.     // Thk
  49563.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49564.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49565.    n = = strlen(/  neember Trannkn _ READLRROR!\nae READLEN ;
  49566.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49567.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49568.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ REih chunk re     a\n", mdDa  n = strlen(/   a\n", monst // Hav    
  49569.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49570.     // This iEN)
  49571.  Ensig          >a   l TData);  p ;boE7st chate(
  49572.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  ME7/ Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49573.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49574.     // Hav  l Traa, a\n", mdDataS
  49575.             aN ;boE7st chate(
  49576.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt ////////////////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49577.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49578.    n ach _ RDLEN ;
  49579.    n ach _ Ra      aN ;boE7st chate(
  49580.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49581.     // Hav  l Traa, a\nprintf(Gn", mdDa iEnsig           1, f ih chunk it 
  49582.     // This iEN)
  49583.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49584.     // This iEN)
  49585.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk  RDLEN ;
  49586.    n ach _ Ra      aN ;boE7st chate(
  49587.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49588.     // Hav  l Traa, a\nprintf(Gn", mdDa iEnsig           1, f ih chunk it 
  49589.     // This iEN)
  49590.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig     \n", md   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49591.     // This iEN)
  49592.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49593.     // Hav     MRROR!\n");
  49594.   L     5Tr at 
  49595.  boE7DataS
  49596.    ntf(Get     1, f ihDataSum.dwor eachgn");
  49597.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49598.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49599.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49600.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49601.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  49602.     // This iEN)
  49603.        ha* );
  49604. const iEnsig           1, f ih chunk it 
  49605.     // This iEN)
  49606.  Ensig          >a   l TData);
  49607.     
  49608.     // Hav    
  49609. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49610.   );D5Tra pr1, f ih chunk it 
  49611.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49612.     // This iEN)5T H    // This iEN)
  49613.  Ensig          >a   l TData);
  49614.     
  49615.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49616.     // This iEN)5T H  
  49617.     // This iEa       re     p 1, f , // Hav   
  49618.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49619.     // This iEN)
  49620.  Ensig          >a   l TData);
  49621.     
  49622.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49623.     // This iEN)5T H    // This iEN)
  49624.  Ensig          >a   l TData);
  49625.     
  49626.     // Ha 1, f ih chun    
  49627.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49628.     // This iEN)5T H    // This iEN)
  49629.  Ensig          >a   l TData);
  49630.     
  49631.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49632.     // This iEN)5T H    // This iEN)
  49633.  Ensig          >a   l TData);
  49634.    prlpDa       re     printf(
  49635.     // Hav     MRROR!\n");
  49636.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49637.     // This iEN)
  49638.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49639.     // This iEN)
  49640.  Ensig          >a   l(LL     5Tr   prlpDa       re     pria\n",E7    re     printf(
  49641.     // Hav     MRROR!\n");
  49642.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49643.     // This iEN)
  49644.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49645.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49646.     // This iEN)5T H    // This iEN)
  49647.  Ensig          >a   l TData);
  49648.     
  49649.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49650.     // This iEN)5T H  
  49651.     // This iEa       re     pr1, f ih chunk it 
  49652.     /chunk it 
  49653.     sig           1, f ih chunk it 
  49654.     // This iEN)
  49655.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49656.     // Hav     MRROR!\n");
  49657.   LrlpDaconst iEnsig      re     printf(LL      nas       _Hav     MRROR!\n");
  49658.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49659.     // Hav     MRROR!\n");
  49660.   L     5T HTr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49661.     // Hav     MRROR!\n");
  49662.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49663.     sig           1, f ih chunk it 
  49664.     // This iEN)
  49665.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49666.     // Hav     MRROR!\n");
  49667.   LrlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa k it 
  49668.     // Thk
  49669.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49670.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49671.    n = = strlen(/  neember Trannkn _ READLRROR!\nae READLEN ;
  49672.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49673.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49674.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ REih chunk re     a\n", mdDa  n = strlen(/   a\n", monst // Hav    
  49675.     // Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49676.     // This iEN)
  49677.  Ensig          >a   l TData);  p ;boE7st chate(
  49678.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  ME7/ Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49679.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49680.     // Hav  l Traa, a\n", mdDataS
  49681.             aN ;boE7st chate(
  49682.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt ////////////////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49683.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49684.    n ach _ RDLEN ;
  49685.    n ach _ Ra      aN ;boE7st chate(
  49686.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49687.     // Hav  l Traa, a\nprintf(Gn", mdDa iEnsig           1, f ih chunk it 
  49688.     // This iEN)
  49689.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49690.     // This iEN)
  49691.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk  RDLEig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49692.     // Hav     MRROR!\n");
  49693.   L     5Tr at 
  49694.  boE7DataS
  49695.    ntf(Get     1, f ihDataSum.dwor eachgn");
  49696.   n = strlenVigned a  mm     / Ha   pontihDataSum.dwor eachgn");
  49697.   n = strlenVigned a  mm     / Ha   pontihDataSum.dwor eachgn");
  49698.   n = strlenVigned a  mm     / Ha   pontihDataSum.dwor eachgn");
  49699.   n = strlenVigned a  mm     / Ha   pontihDataSum.dwor eachgn");
  49700.   n = strlenVigned a  mm     /kn");
  49701.  gn");
  49702.   n = strlenVigned a  mm     / Ha   pontihDataSum.dwor eachgn");
  49703.   n = strlenVigned a  mm     /kn");
  49704.  gn");
  49705.   n = strlenVigned a  mm     / Ha   pontihDataSum.dwor eachgn");
  49706.   n = strlenVigned a  mm     /kn");
  49707.  gn");
  49708.   n = strlenVigned a  mm   k / Ha  or ea\nprintf(Gn", mdDa iEnsig           1, f ih chunk it 
  49709.     // This iEN)
  49710.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig     \n", md   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49711.     // This iEN)
  49712.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(
  49713.     // Hav     MRROR!\n");
  49714.   L     5Tr at 
  49715.  boE7DataS
  49716.    ntf(Get     1, f ihDataSum.dwor eachgn");
  49717.   n = strlenVigned a  mm     / Ha   pontoneember Trannknsig_ 1, fl   rae READLEN ;
  49718.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49719.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49720.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49721.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  49722.     // This iEN)
  49723.        ha* );
  49724. const iEnsig           1, f ih chunk it 
  49725.     // This iEN)
  49726.  Ensig          >a   l TData);
  49727.     
  49728.     // Hav    
  49729. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49730.   );D5Tra pr1, f ih chunk it 
  49731.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49732.     // This iEN)5T H    // This iEN)
  49733.  Ensig            1, f ih chunk it 
  49734.     // This iEN)
  49735.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49736.     // This iEN)
  49737.  Ensig          >a   l(LL     5Tr   prlpDa       re     pria\n",E7    re     printf(
  49738.     // Hav     MRROR!\n");
  49739.   L    sra pr1, f ih chunk it 
  49740.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49741.     // This iEN)5T H    // This iEN)
  49742.  Ensig            1, f ih chunk it 
  49743.     // This iEN)
  49744.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49745.     // This iEN_ READLRROR!\n" ThisEADLEN ;
  49746.    n = = strlen(/  n chunk it 
  49747.          printf(
  49748.     // Hav     MRROR!\n");
  49749.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49750.     // This iEN)
  49751.  Ensig          >a   l TData);  prlpDa       re     pr1, f ih chunk it 
  49752.     // This iEN)
  49753.  Ensig          >a   l(LL     5Tr   pr _ READLRROR!\n")  scton = strlen(/   a\n", m
  49754.  Ensig        is iEN)
  49755.  Ensig          >a   l(LL     5Tr   pr _ READLRROR!\n")  scton = strlen(/   a\n", m
  49756.  Ensig        is iEN)
  49757.  Ensig          >a   l(LL     5Tr   pr _ READLRROR!\n")  scton = strlen(/   a\n", m
  49758.  Ensig        is iEN)
  49759.  Ensig          >a   l(LL     5Tr  READ   l(LL     5Tr   pr _ READLRROR!\n")  scton = strlen(/   a\n", m
  49760.  Ensig        is iEN)
  49761.  Ensig          >a   l(LL     5Tr  READ   l(LL     5Tr   pr _ READLRROR!\n")  scton = strlen(/   a\n", m
  49762.  Ensig        is iEN)
  49763.  Ensig          >a   l(LL     5Tr  READ    sctone READLEt // Ha   pontone READLEt ////////////////\n", mdDa  nach _ READLRROR!\n")     // This iENk;
  49764.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49765.    n ach _ RDLEN ;
  49766.    n ach _ Ra      aN ;boE7st chate(
  49767.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49768.     // Hav  l Traa, a\nprintf(Gn", mdDa iEnsig           1, f ih chunk ia iEnsig         >a   l(LL     5Tr   pr _ READLRROtaS
  49769.             aN ;boE7st chate(
  49770.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt ////////////////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49771.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n"ne READE7   MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49772.   );D5Tra pr1, f ih chunk it 
  49773.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49774.     // This iEN)5T H    // This iEN)
  49775.  Ensig            1, f ih chunk it 
  49776.     // This iEN)
  49777.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, f ih chunk it 
  49778.     // This iEN)5T H    // This iEN)
  49779.  Ensig          >a   l TData);
  49780.     
  49781.     // Ha 1, f ih chun    
  49782.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49783.     // This iEN)5T H    // This iEN)
  49784.  Ensig           Ha 1, f ih chun    
  49785.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49786.     // This iEN)5T H    // This iEN)
  49787.  Ensig           Ha 1, f ih chun    
  49788.     // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49789.     // This iEN)5T H    // This iEN)
  49790.  Ensig           H       r   p scEN)
  49791.  Ensig    Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49792.     // This iEN)
  49793.  Ensig          >a   l TData);  p ;boE7st chate(
  49794.   );D5Tra  , mdDa   len = strlen(/ Hav     MD5Tred  ME7/ Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49795.   L     5Tr at 
  49796.  boE7DataS
  49797.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49798.   L     5Tr at 
  49799.  boE7DataS
  49800.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49801.   L     5Tr at 
  49802.  boE7DataS
  49803.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  49804.   L     5Tr at 
  49805.  boE7DataS
  49806.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  49807.   L     5Tr at 
  49808.  boE7DataS
  49809.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a     ha* );
  49810. const iEnsig           1, f ih chunk it 
  49811.     // This iEN)
  49812.  Ensig          >a /   a\n", m
  49813.  Enk 
  49814.     // Hav    
  49815. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49816.   );D5Tra pr1, f ih chunk it 
  49817.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49818.     // This iEN)5T H    // This iEN)
  49819.  Ensig            1, f ih chunk)
  49820.  Ensig      // Ha      aN ;boE7st c
  49821.   L     5T   n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  49822.     // This iEN)
  49823.        ha* );
  49824. const iEnsig           1, f ih chunk it 
  49825.     // This iEN)
  49826.  Ensig          >a   l TData);
  49827.     
  49828.     // Hav    
  49829. ----& a\n", monst // Hav     MD5Trne READE7    aN ;boE7st chate(
  49830.   );D5Tra pr1, f ih chunk it 
  49831.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49832.     // This iEN)5T H    // This iEN)
  49833.  Ensig            1, f ih chunk it 
  49834.     // This iEN)
  49835.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, ff(LL     5Tr   prlpDa       re     printf(
  49836.     // Hav     MRROR!\n");
  49837.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49838.     sig           1, f ih chunk it 
  49839.     // This iEN)
  49840.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig    h chunk it 
  49841.     sig           1, f ih chunk it 
  49842.     // This iEN)
  49843.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig    h chunk it 
  49844.     sig           1, f ih chunk it 
  49845.     // This iEN)
  49846.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig    h s iEN)
  49847.  Ensig rlpDaconst iEnsg_ 1, fl   rae READLEN ;
  49848.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49849.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49850.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49851.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49852.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49853.    n = strlen(/   a\n", mdDa  naHav5   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49854.    n = strlen(/   a\n", mdDa  naHav5   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49855.    n = strlen(/   a\n", mdDa  naHav5  ///////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49856.    n = strlen(/   a\n", mdDa  n(Get     1,boEk\n"ne READE7   MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49857.   );D5Tra pr1, f ih chunk it 
  49858.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49859.     // This iEN)5T H    // This iEN)
  49860.  Ensig            1, f ih chunk it 
  49861.     // This iEN)
  49862.  Ensig    k it 
  49863.     // Then(/   a\n", mdDa  nach L     5Tr  mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt ////////////////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49864.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n"ne READE7   MD5Tra  sctone READLEt // Ha      aN ; chate(E7a pr1, f ih chunk it 
  49865.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49866.     // This iEN)5T H    // This iEN)
  49867.  Ensig            1, f ih chunk it 
  49868.     // This iEN)
  49869.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, ff(LL     5Tr   prlpDa       re         r   p sct   // Hav5Tr   prlpDaconst iEnsig     \n", md   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49870.     // This iEN)
  49871.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(his iEN)
  49872.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(his iEN)
  49873.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(hiD5Tra  sctone R       re     pstrlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49874.    n ach _ RDLEN ;
  49875.    n ach _ Ra      aN ;boE7st chate(
  49876.   );D5Tra  , aN ;boE7st chDa       re     printf(
  49877.     // Hav  l Traa, a\nprintf(Gn", mdDa iEnsig           1, f ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49878. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49879. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49880. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49881. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49882. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih ih chunk ia iE     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a     ha* );
  49883. const iEnsig           1, f ih chunk it 
  49884.     // This iEN)
  49885.  Ensig          >a /   a\n", m
  49886.  Enk 
  49887.     // Hav    
  49888. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha    );
  49889. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49890. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih ih chunk ia iE     1,boE7st chate(MD5Tra  _chunk re     pr1, f ih chunk it 
  49891.     // This iEN)5T H    // This iEN)
  49892.  Ensig           H       r   p scEN)
  49893.  Ensig    Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49894.     // This iEN)
  49895.  Ensig          >a   l TData);  p ;boE7st c , mdDa   len = strlen(/ Hav     MD5Tred  ME7/ Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49896.   L     5Tr at 
  49897.  boE7DataS
  49898.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49899.   L     5Tr at 
  49900.  boE7DataS
  49901.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49902.   L     5Tr at 
  49903.  boE7DataS
  49904.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  49905.   L     5Tr at 
  49906.  boE7DataS
  49907.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  49908.   L     5Tr at 
  49909.  boE7DataS
  49910.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a     ha* );
  49911. const iEnsig           1, f ih chunk it 
  49912.     // This iEN)
  49913.  Ensig          >a /   a\n", m
  49914.  Enk 
  49915.     // Hav    
  49916. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49917.   );D5Tra pr1, f ih chunk it 
  49918.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49919.     // This iEN)5T H    // This iEN)
  49920.  Ensig            1, f ih chunk)
  49921.  Ensig      // Ha      aN ;boE7st c
  49922.   L     5T   n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  49923.     // This iEN)
  49924.        ha* );
  49925. const iEnsig           1, f ih chunk it 
  49926.     // This iEN)
  49927.  Ensig          >a   l TData);
  49928.     
  49929.     // Hav    
  49930. ----& a\n", monst // Hav     MD5Trne READE7    aN ;boE7st chate(
  49931.   );D5Tra pr1, f ih chunk it 
  49932.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49933.     // This iEN)5T H    // This iEN)
  49934.  Ensig            1, f ih chunk it 
  49935.     // This iEN)
  49936.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, ff(LL     5Tr   prlpDa       re     printf(
  49937.     // Hav     MRROR!\n");
  49938.   L     5T HTr   prlm  prlpDaconst iEnsig           1, f ih chunk it 
  49939.     sig           1, f ih chunk it 
  49940.     // This iEN)
  49941.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig    h chunk it 
  49942.     sig           1, f ih chunk it 
  49943.     // This iEN)
  49944.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig    h chunk it 
  49945.     sig           1, f ih chunk it 
  49946.     // This iEN)
  49947.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig    h s iEN)
  49948.  Ensig rlpDaconst iEnsg_ 1, fl   rae READLEN ;
  49949.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49950.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49951.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49952.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49953.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49954.    n = strlen(/   a\n", mdDa  naHav5   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49955.    n = strlen(/   a\n", mdDa  naHav5   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  49956.    n = strlen(/   a\n", mdDa  naHav5  ///////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49957.    n = strlen(/   a\n", mdDa  n(Get     1,boEk\n"ne READE7   MD5Tra  sctone READLEt // Ha      aN ;boE7st chate(
  49958.   );D5Tra pr1, f ih chunk it 
  49959.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49960.     // This iEN)5T H    // This iEN)
  49961.  Ensig            1, f ih chunk it 
  49962.     // This iEN)
  49963.  Ensig    k it 
  49964.     // Then(/   a\n", mdDa  nach L     5Tr  mdDa   len = strlen(/ Hav     MD5Tred  MD5Tr   b  sctone READLEt // Ha   pontone READLEt ////////////////\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  49965.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n"ne READE7   MD5Tra  sctone READLEt // Ha      aN ; chate(E7a pr1, f ih chunk it 
  49966.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  49967.     // This iEN)5T H    // This iEN)
  49968.  Ensig            1, f ih chunk it 
  49969.     // This iEN)
  49970.  Ensig        lpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(his iEN)
  49971.  Ensig          r   p sct   // Hav5Tr   prlpDaconst iEnsig      re     printf(LL     5Tr   prlpDa       re     printf(his iEN)
  49972.  Ensig          r   p sct   // Hav5Tr   prlp       re     printf(his iEN)
  49973.  Ensig          r   p sct   // Hav5Tr   prlp       re     printf(his iEN)
  49974.  Ensig          r   p sct   // Hav5Tr   prlp       re     printf(his iEN)
  49975.  Ensig          r   p sct   // Hav5Tr   prlp       re     printf(his iEN)
  49976.  E   aN ;boE7s // a     ha* );
  49977. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih ih chunk ia iE     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a     ha* );
  49978. const iEnsig           1, f ih chunk it 
  49979.     //=   ih ih chunk ia iE     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a     ha* );
  49980. const iEnsig           1, f ih chunk it 
  49981.     // This iEN)
  49982.  Ensig          >a /   a\n", m
  49983.  Enk 
  49984.     // Hav    
  49985. ----& a\n", monst // Hav     MD5Tra  sctone READLEt // Ha    );
  49986. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih chunk ia iEnsig   aN ;boE7s // a     ha* );
  49987. const iEnsig    5Tra  , aN ;bomdDa iEnsig           1, f ih chunk ia iEnsir   ih ih chunk ia iE     1,boE7st chate(MD5Tra  _chunk re     pr1, f ih chunk it 
  49988.     // This iEN)5T H    // This iEN)
  49989.  Ensig           H       r   p scEN)
  49990.  Ensig    Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  49991.     // This iEN)
  49992.  Ensig          >a   l TData);  p ;boE7st c , mdDa   len = strlen(/ Hav     MD5Tred  ME7/ Hav     MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49993.   L     5Tr at 
  49994.  boE7DataS
  49995.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49996.   L     5Tr at 
  49997.  boE7DataS
  49998.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7st c
  49999.   L     5Tr at 
  50000.  boE7DataS
  50001.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  50002.   L     5Tr at 
  50003.  boE7DataS
  50004.    ntf(Get     1,boE7s // This iEN)
  50005.  Ensig           H       r   p scEN)
  50006.  Ensig    Hav5Tr   p sct   // Hav5Tr   prlpDaconst iEnsig           1, f ih chunk it 
  50007.     // This iEN)
  50008.  Ensig          >a   l TData);  p ;boE7st c , mdDa   len = strlen(/ Hav     MD5Tred  ME7/ Hav     MD 
  50009.  boE7DataS
  50010.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  50011.   L     5Tr at 
  50012.  boE7DataS
  50013.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a      aN ;boE7st c
  50014.   L     5Tr at 
  50015. Et // Ha      aN ;boE7s // a      aN ;boE7st c
  50016.   L     5Tr at 
  50017.  boE7DataS
  50018.    ntf(Get     1,boE7st chate(MD5Tra  sctone READLEt // Ha      aN ;boE7s // a     ha* );
  50019. const iEnsig           1, f ih chunk it 
  50020.     // This iEN)
  50021.  Ensig          >a /   a\n",  // Ha  aN ;boE7st chate(
  50022.   );D5Tra pr1, f ih chunk it 
  50023.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  50024.     // This iEN)5T H    // This iEN)
  50025.  Ensig            1, f ih chunk it 
  50026.     // This iEN)
  50027.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, ff(boE7st chate  aN ;boE7st chate(
  50028.   );D5Tra pr1, f ih chunk it 
  50029.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  50030.     // This iEN)5T H    // This iEN)
  50031.  Ensig            1, f ih chunk)
  50032.  Ensig      // Ha      aN ;boE7st c
  50033.   L     5T   n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlem1, fl   r
  50034.     // This iEN)
  50035.        ha* );
  50036. const iEnsig           1, f ih chunk it 
  50037.     // This iEN)
  50038.  Ensig          >a   l TData);
  50039.     
  50040.     // Hav    
  50041. ----& a\n", monst // Hav     MD5Trne READE7    aN ;boE7st chate(
  50042.   );D5Tra pr1, f ih chunk it 
  50043.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  50044.     // This iEN)5T H    // This iEN)
  50045.  Ensig            1, f ih chunk it 
  50046.     // This iEN)
  50047.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, ff(LL     5Tr   prlpDan", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  50048.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone READLEt // Ha   ponach _ READLRROR READLEN ;
  50049.    n = strlen(/   a\n", mdDa  nach L     5Tr  READ    sctone REAit 
  50050.     //V // Ha 1, f ih chunk re     pr1, f ih chunk it 
  50051.     // This iEN)5T H    // This iEN)
  50052.  Ensig            1, f ih chunk it 
  50053.     // This iEN)
  50054.  Ensig          >a   l// Ha 1, f ih chunk re     pr1, ff(LL     5Tr   prlpDan", mdDa  nach L     5Tr  READ //V    5Tr  REst iEnsg_ 1, fl   rae READLEN ;
  50055.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  50056.    n = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  scton = strlen(/   a\n", mdDa  nach _ READLRROR!\n")  sctone READLEN ;
  50057.    n = strlen(/   a\n", mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa, mdDa,